This is really really weird. I have no clue what has happened to my system. Look the following. Isn't it funny? You see, the little program Hello.java has no problem at all. And this is strangely proved if I run this program by clicking on the execute button from JCreator Pro. It runs pretty well that way. But if I run it from the DOS Window. I have the weird exception java.lang.NoClassDefFoundError: Hello What might be the problem? If the JVM is damaged, then it should not have run from JCreator Pro, right? The problem persists regardless of which java.exe I run, be it the one under JAVA_HOME\bin or the one under C:\WINNT\system32. Any explanation please? Thank you! *** Start of the funny java **** C:\Java>type Hello.java public class Hello { public static void main(String [] args) { System.out.println("Hello, world!"); } } C:\Java>javac Hello.java C:\Java>java Hello Exception in thread "main" java.lang.NoClassDefFoundError: Hello C:\Java>java -version java version "1.4.1_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01) Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode) C:\Java> **** End of the funny java ****
Maulin Vasavada
Ranch Hand
Joined: Nov 04, 2001
Posts: 1863
posted
0
try running, java -cp .;%CLASSPATH% Hello and see if that works... regards maulin.
You apparently have your classpath set up just fine for your IDE (JCreator) but do NOT have it set up outside the IDE. You can invoke the program naming the classpath to use (as shown above) or just set your classpath on your machine.
"JavaRanch, where the deer and the Certified play" - David O'Meara