Click to See Complete Forum and Search --> : Learning Java


William Burns, Jr.
March 16th, 1999, 05:23 PM
I am trying to learn the language Java, but am having problems. I entered the following Java program:


class Example1 {

public static void main(String args[]) {

System.out.println("This is the output from Example1");

}

}


I saved the program as Example1.java, compiled it: javac Example1.java and the Example1.class file was produced, but

when I entered:


java Example1


I got the following error message:


Exception in thread "main" java.lang.NoClassDefFoundError: Example1


I am using JDK1.2. My path statement points to its bin folder. Any help as to why I am getting this error message or

what I am doing wrong would help. I am using the book Teach Yourself Java by Joesph O'Neil. The above example came

directly out of his book.


Thanks...

Saketharaman
March 17th, 1999, 12:44 AM
I run the above code in my system. It works fine. My path also points to jdk1.2\bin. The exception you have mentioned happens when JRE is not able to find the Example1.class and has nothing to do with the PATH. Java is very case sensitive so be sure you take care of it. Your error could because of this. Also be sure you run java Example1 from the directory where Example1 is residing. Otherwise give the fullyqualfied file name.

Satya Dev
March 19th, 1999, 05:21 AM
Hi!,


I tested the program It is working fine. What I supect is though you have JDK1.2 in your mechine the java compiler your

are using could be an obsolate on. In the older versions CLASSPATH variable has to be set as follows


set cllasspath=.;c:\jdk1.1.6\lib;classes.zip;


and I assume your path variable is as follows.


path=c:\jdk1.1.6\bin;c:\jdk1.2\bin;


In the above case the java compiler is from JDK 1.1.6 not from jdk1.2


I don't know how far I am correct. But the problem could be with path some settings only.


Satya