I have a small java program(the smiplest I can have). When I tried to
run after compling it, it shows the error:
Exception in thread "main" java.lang.NoClassDefFoundError: test
what might go wrong?
--------------------------------------------------here is what I did
-------------------------
C:\>type test.java
public class test{
public static void main(String[] args){
System.out.println("OK");
}
}
C:\>javac test.java
C:\>dir test.*
Volume in drive C has no label.
Volume Serial Number is B496-E852
Directory of C:\
02/20/2006 02:27 PM 404 test.class
02/20/2006 09:51 AM 93 test.java
2 File(s) 497 bytes
0 Dir(s) 11,949,969,408 bytes free
C:\>java test
Exception in thread "main" java.lang.NoClassDefFoundError: test
C:\>
send2r@gmail.com - 20 Feb 2006 20:38 GMT
It is a CLASSPATH problem
java is not able to find your class correctly.
since you are on DOS do the following:
before running your calss -
C:\>echo %CLASSPATH%
C:\>set CLASSPATH=C:\;%CLASSPATH%
C:\>java test
Now it should work
note:
step C:\>echo %CLASSPATH% is not necessary. But I asked to do so to
make sure that you have some other folder paths in classpath, that
makes your class invisible.
Also, specifying '.' to represant current dir rather than actual
path(like C:\) would be better
ie;
set CLASSPATH=.;%CLASSPATH% instead of step two.
HTH
RC
> I have a small java program(the smiplest I can have). When I tried to
> run after compling it, it shows the error:
[quoted text clipped - 29 lines]
>
> C:\>
Roedy Green - 24 Feb 2006 20:34 GMT
>NoClassDefFoundError
see http://mindprod.com/jgloss/caq.html

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.