I had installed java in c: drive.
I had set a path lilke this C:\Program Files\Java\jdk1.6.0_05\bin;.;
The program compiles fine but at run time it throw exception as NoClassDeffFoundError.
Exception in thread "main" java.lang.NoClassDefFoundError: Test Caused by: java.lang.ClassNotFoundException: Test
at java.security.AccessController.doPrivileged(Native Method)
Thanks in advance
Life is easy because we write the source code.....
First things first.. PATH and CLASSPATH are different and you got to mention it as CLASSPATH , when you mean CLASSPATH.Secondly when you use -classpath option , it means you are overiding your CLASSPATH value sent in your environment.
So , in the first case it worked because your class lies in the present working directory (pwd) and your -classpath option says "." , which means look for classes only pwd.
In next case , you have not specified so it uses the CLASSPATH value defined in the environment. But your CLASSPATH should either have complete path where Test.class lies or the "." in order for it to find the class. So make sure you add "." to your CLASSPATH variable as well.