Error: Could not find or load main class HelloWorld.java

My program compiles fine:

$ javac HelloWorld.java


But when I run it I get the following error:

$ java HelloWorld.java
Error: Could not find or load main class HelloWorld.java



Try to run it without the .java extension:

$ java HelloWorld
Hello, World