Java – Could not find or load main class

javawindows

I have Windows 7, installed jdk1.7.0 and its supporting jre7.
My problem is compilation part works perfectly, but while running the Java program I get this error saying:

"Could not find or load main class"

I am storing all my programs in javalab folder. I have set the path to it. Procedure looks like this:

C:\Users\user>cd\

C:\>cd javalab

C:\javalab>autoexec.bat

C:\javalab>set path=C:\Program Files\Java\jdk1.7.0\bin

C:\javalab>javac p1.java

C:\javalab>java p1
Error: Could not find or load main class p1

C:\javalab> 

Best Answer

I was having a similar issue with my very first java program.

I was issuing this command

java HelloWorld.class

Which resulted in the same error.

Turns out you need to exclude the .class

java HelloWorld