This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark ""Error: Could not find or load the main class..." ERROR..!" Watch ""Error: Could not find or load the main class..." ERROR..!" New topic
Author

"Error: Could not find or load the main class..." ERROR..!

Prats Shah
Greenhorn

Joined: Feb 28, 2013
Posts: 9
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.


[Thumbnail for JAVA Error.JPG]

Saif Asif
Ranch Hand

Joined: Aug 11, 2011
Posts: 440

Greetings Prats Shah ,

I found your mistake, AFTER compiling the code , instead of typing java First.class , just type java First and it will work fine.


Muhammad Saif Asif Mirza
OCJA(5/6) OCJP(6) OCJWCD(6)
Prats Shah
Greenhorn

Joined: Feb 28, 2013
Posts: 9
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.
Prats Shah
Greenhorn

Joined: Feb 28, 2013
Posts: 9
Aah..! Thank You very much Sir. Thanks a lot..!
Saif Asif
Ranch Hand

Joined: Aug 11, 2011
Posts: 440

Your wellcome :-)

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: 9
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: 38509
    
  23
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: "Error: Could not find or load the main class..." ERROR..!