Error: Could not find or load main class in intelliJ IDE Error: Could not find or load main class in intelliJ IDE java java

Error: Could not find or load main class in intelliJ IDE


This might help:

1) "Build" menu -> "Rebuild Project".Sometimes Intellij doesn't rewrite the classes because they already exist, this way you ask Intellij to rewrite everything.

2) "Run" menu -> "Edit configuration" -> delete the profile -> add back the profile ("Application" if it's a Java application), choose your main class from the "Main Class" dropdown menu.

3)"Build" menu -> "Rebuild Project".


If none of the above answers worked for you, just close your IntelliJ IDE and remove the IntelliJ IDE file and folder from the root of your project:

rm -rf .idea *.iml 

Then open the project with IntelliJ. It must work now.


For me the solution was to fix the output directory under project settings. Before I was using just "target" for the Project compiler output. Instead I updated it to have a full path e.g. D:\dev\sigplusjava2_68\targetenter image description here