This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes could not find or load the main class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "could not find or load the main class" Watch "could not find or load the main class" New topic
Author

could not find or load the main class

a k m shamsudoha
Greenhorn

Joined: Apr 09, 2013
Posts: 14
why find the problem when i try to run this code which is in d:\world directory and my package name is world
the problem is given below
C:\Documents and Settings\Administrator>D:

D:\>CD world

D:\world>set CLASSPATH=.;d:;

D:\world>javac HelloWorld.java

D:\world>java world.HelloWorld
Error: Could not find or load main class world.HelloWorld

my java code is given below

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37902
    
  22
Welcome to the Ranch

I have added code tags which you should always use, and you can see how much better your post looks
Don’t set a classpath for such a simple app. You can only find the class of that name from outside the world folder. Try
cd ..
java world.HelloWorld
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: could not find or load the main class
 
Similar Threads
Java problem: Could not find or load class
Classpath error
[Ant] Run a jar file throw java.lang.NoClassDefFoundError: app/main/Main and Could not find the main
Java Error
Trouble with packages!