aspose file tools*
The moose likes Beginning Java and the fly likes Java file is compiling but not running. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java file is compiling but not running." Watch "Java file is compiling but not running." New topic
Author

Java file is compiling but not running.

Rajesh Shekar
Greenhorn

Joined: Feb 25, 2012
Posts: 8
Hi All,
Im new to java and i wrote a new java program which will display hello world. I named the java file as Hello.Java and the file resides in my D drive. When i compiled it it worked fine. But when i try to run it i got an error as below,
Exception in thread "main" java.lang.NoClassDefFoundError: Hello
Can someone help me with this error?
Greg Brannon
Bartender

Joined: Oct 24, 2010
Posts: 561
Can we see the source code?


Always learning Java, currently using Eclipse on Fedora.
Linux user#: 501795
Rajesh Shekar
Greenhorn

Joined: Feb 25, 2012
Posts: 8
Please find the code below
Greg Brannon
Bartender

Joined: Oct 24, 2010
Posts: 561
Is the name of the source file "Hello.java"? If not, it should be.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
How are you running the code? The command should be something like "java -cp . Hello" while you are in the same directory as the Hello.class file.
Rajesh Shekar
Greenhorn

Joined: Feb 25, 2012
Posts: 8
Yes i run from command line what does cp means?
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
java cp option

Have you tried it?
Rajesh Shekar
Greenhorn

Joined: Feb 25, 2012
Posts: 8
Hi All,

Thanks a lot to all of the friends here after setting the class path my code worked fine.
 
 
subject: Java file is compiling but not running.