The Java Virtual Machine refers to the CLASSPATH environment variable to locate Java classes. Some programs modify the CLASSPATH in a way that causes the Java command-line tools to fail with the error message
Code:
Exception in thread "main" java.lang.NoClassDefFoundError: className
where className is the name of the Java program (e.g., Welcome1). To correct this problem, use the -classpath command-line argument when compiling and running your programs. For example, to compile Welcome1.java, type
Code:
javac -classpath . Welcome1.java
To execute the program, type
Code:
java -classpath . Welcome1
The "." tells the compiler and virtual machine to look in the current directory for classes. Alternatively, you can permanently remove the CLASSPATH environment variable on Windows 2000 and Windows XP by going into the System control panel, selecting the Advanced tab, clicking the Environment Variables button and removing the CLASSPATH entry from the User variables and System variables boxes.
Bookmarks