"Error: Could not find or load the main class..." ERROR..!
Prats Shah
Greenhorn
Joined: Feb 28, 2013
Posts: 7
posted
0
I can compile my "HelloWorld" program successfully but not able to run it. I think a picture can describe more than thousand words. So I am uploading image here as my problem. Please ignore "HelloWorld" Code as I have copied it from your site only and also class name is same as file name . I have changed just classname and filename with "First" instead of "HelloWorld". Here is my query in image.
I found your mistake, AFTER compiling the code , instead of typing java First.class , just type java First and it will work fine.
Regards, Muhammad Saif Asif Mirza
SCJA(5/6) SCJP(6)
Prats Shah
Greenhorn
Joined: Feb 28, 2013
Posts: 7
posted
0
Prats Shah wrote:I can compile my "HelloWorld" program successfully but not able to run it. I think a picture can describe more than thousand words. So I am uploading image here as my problem. Please ignore "HelloWorld" Code as I have copied it from your site only and also class name is same as file name . I have changed just classname and filename with "First" instead of "HelloWorld". Here is my query in image.
Just for the information , the .class extension means that it is the class file containing java byte code which the java compiler created when you issue the javac command .
Prats Shah
Greenhorn
Joined: Feb 28, 2013
Posts: 7
posted
0
Yes , So if after compilation we want to run the file which is obviously has Bytecodes, so why I can't run with First.class filename? (i.e java First.class)
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32654
4
posted
0
Welcome to the Ranch
You can only say, because that is what the java tool is programmed to accept. You are not executing the file, but the class. The class is called First, not First.class.