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


Win a copy of Java 8 in Action this week in the Java 8 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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java file is compiling but not running.
 
Similar Threads
Eclipse can not find the OWL (ontology model file)
Package & Compilation Problem
about packege
error after installing java 1.4
compile interface error