IntelliJ Idea "could not find or load main class"

I installed IntelliJ Idea and I had a few working Java projects already on my system, but when I open and run a program from these projects the above-mentioned error is shown. I am also unable to create any new Java classes in these projects. But when I made a new project through IntelliJ no problems occurred. The problem happens only with existing projects.

2 Answers

I guess you should mark the certain folder java (whose location is src/main/java in project) as sources:

  1. Right Click java folder
  2. Mark Directory as
  3. Sources Root

Image explanation:

enter image description here

Look like you were having a compilation issue, please check the configuration in the project settings/structure

  1. Project: SDK and language level
  2. Modules: src, target

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like