I am trying to write, compile and run a simple "Hello World" Java program. It compiles fine but when I try to run it I get a NoClassDefFoundError.
My j2sdk resides at the top level directory on the C drive - ie c:\j2sdk1.4.2_12\bin, and my JAVA_HOME is set to c:\j2sdk1.4.2_12. My path and classpath are both set to c:\j2sdk1.4.2_12\bin. In my DOS shell it all looks like this ...
Your CLASSPATH is set wrong. The CLASSPATH is where Java looks for *.class files. The Windows system directories and the bin directory of the JDK do not belong in the CLASSPATH - those directories do not contain *.class files that Java uses.
So, remove those directories from the CLASSPATH. As Ernest says, it's best not to set the CLASSPATH at all. If you do set the CLASSPATH, add "." to it, which means "the current directory". For example: