What causes Java "Could not find or load main class" error?


Your thoughts?

imDifferent |

This happens when Java can't find or load the class running your application.

It sounds obvious but this error can happen for very frustrating reasons like:

IDE configurations if these are off then your JRE may not look for things in the right places. Specifically if you've configured the wrong class as the main entry point of your application you're going to have issues...

Wrong Class Name like if you run your program with helloworld and the class is defined as HelloWorld...

Wrong extension like when you run "java HelloWorld.java" when you should run "java HelloWorld"...

Wrong Class Path like when you run your application specifying the -cp argument and it points to the wrong place...or if you run your application from the wrong directory.