Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

err message

 
Dishi Malhotra
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Dishi Malhotra
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how class path is set
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic