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 Java file is compiling but not running. 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 "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: 557
Can we see the source code?


Learning Java using Eclipse on OpenSUSE 11.2
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: 557
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Java file is compiling but not running.