Error:
/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home/bin/java
-javaagent:/Applications/IntelliJ IDEA CE.app/Contents/lib/idea_rt.jar=53049:
/Applications/IntelliJ IDEA CE.app/Contents/bin -Dfile.encoding=UTF-8 Scratch
Error: Could not find or load main class HelloWorld
Caused by: java.lang.ClassNotFoundException: HelloWorld
Process finished with exit code 1
Class File:
public class HelloWorld {
public static void main(String... args) {
System.out.println("Hello");
}
}
As you can see the above class does not have any complication issues or syntax errors. There can be multiple reasons that you may get the error, below are some of the solutions that may work for you!
- Make sure that the class name is correct.
- Go to Menu: Build -> Re-Build Project.
- Remove .idea directory from your project and restart IDE.
- Go to Files: Invalidate Cache/ Restart...
- Check your project has a out folder, if not create one, example: /Users/code2care/IdeaProjects/java-examples/out
- Edit Build/Run Configurations and check if you have selected the correct Java class that has a main method.

Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!