John Jai wrote:1. Please check if the .class file is present in the classpath
2. Hope you first compiled using javac before executing java command.
abheeshek reddy wrote:
John Jai wrote:1. Please check if the .class file is present in the classpath
2. Hope you first compiled using javac before executing java command.
Thanks John for prompt response,
Usual practice is we won't set individual .class files in classpath. However, previously i used to set only path variable in system variables. if required i used set rt.jar file in class path.
thanks
Regards,
Anayonkar Shivalkar (SCJP, SCWCD, OCMJD, OCEEJBD)
abheeshek reddy wrote:The path has been set to my C:\Program Files\Java\jdk1.6.0_31\bin directory.
Ravi Vanamala wrote:Along with the PATH, try setting the JAVA_HOME=C:\Program Files\Java\jdk1.6.0_31 in environment "System Variables"
Jesper de Jong wrote:
abheeshek reddy wrote:The path has been set to my C:\Program Files\Java\jdk1.6.0_31\bin directory.
What the PATH is set to, is irrelevant for this question.
Ravi Vanamala wrote:Along with the PATH, try setting the JAVA_HOME=C:\Program Files\Java\jdk1.6.0_31 in environment "System Variables"
That's not going to solve anything either - the Java compiler and launcher do not use the JAVA_HOME environment variable at all.
NoClassDefFoundError means that your CLASSPATH is not correct, so that Java can't find a class it's looking for.
First, compile your source file with the command: javac SingletonDemo.java
If that succeeds without errors, check that you have a file named SingletonDemo.class in the current directory.
Then run it. Use the -cp option to specify the classpath; make sure the current directory "." is in the classpath:
java -cp . SingletonDemo