aspose file tools*
The moose likes Beginning Java and the fly likes err message Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "err message" Watch "err message" New topic
Author

err message

Dishi Malhotra
Greenhorn

Joined: Dec 13, 2000
Posts: 22
when ever i compile any program on my system it compiles sucessfuly but when i run any program it gives error i don't know what to do the error message is as follows:
C:\jdk1.2\bin>javac example.java
C:\jdk1.2\bin>java example
Exception in thread "main" java.lang.NoClassDefFoundError: example
the example.java is as follows:
class example
{
public static void main(String args[])
{
System.out.println("This is my first java program.");
}
}
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
First make sure that your path and classpath is set to or includes that directory.
Also make sure that your file name is example.java.

"JavaRanch, where the deer and the Certified play" - David O'Meara
Dishi Malhotra
Greenhorn

Joined: Dec 13, 2000
Posts: 22
how class path is set
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
This is how mine is set.
PATH c:\jdk1.2.1\bin;c:\jdk1.2.1\WHEREYOURCODEIS;c:\ora8;%PATH%;
set CLASSPATH=c:\jdk1.2.1\WHEREYOURCODEIS;c:\jdk1.2.1\bin;
You can either edit you autoexec file or I have a p.bat file that I uses to just concatenate the java files on the fly. That way I can switch versions of java without rebooting. I just edit the p.bat file, close the current DOS window and get a new window.

Bharath Srinivasan
Greenhorn

Joined: Feb 04, 2001
Posts: 2
Does that mean CLASSPATH is that place where ur .class files are stored or the place where ur executables (javac,java) are....??
please confirm.
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
"path" should include the place where the SUN provided executables are.
CLASSPATH should contain the place that your application code is stored.
Here is an official definition:
http://developer.java.sun.com/developer/onlineTraining/Programming/BasicJava1/windows.html
 
 
subject: err message