aspose file tools
The moose likes Beginning Java and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply 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: 7
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: 294

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.


Regards, Muhammad Saif Asif Mirza
SCJA(5/6) SCJP(6)
Prats Shah
Greenhorn

Joined: Feb 28, 2013
Posts: 7
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: 7
Aah..! Thank You very much Sir. Thanks a lot..!
Saif Asif
Ranch Hand

Joined: Aug 11, 2011
Posts: 294

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: 7
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
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.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: "Error: Could not find or load the main class..." ERROR..!
 
Similar Threads
ejb on weblogic
the 1st JSP app with 404 error
Why does my java program only run with -debug in my parameters
Deploying Servlet in Tomcat 5.0
WSDL access error