CLASSPATH is an environment variable which tells the Java compiler and the JVM where to look for Java class files.

In Java 1.2 and later, the CLASSPATH variable is less critical because Java knows how to find the default classes and because Java loads classes from the current directory by default.

If you do not want to use an environment variable, you can use the -classpath argument to the Java compiler or the JVM as such:

javac -classpath . JavaProg

To add a jar file to your CLASSPATH, include the entire pathname of the jar file — including the filename.

Setting the CLASSPATH in Microsoft Windows XP

Unlike Unix, setting environment variables in Windows can be somewhat difficult.

To configure a persistent CLASSPATH under Windows XP:

  1. Click the Start Button
  2. Select the Control Panel
  3. Click Switch to Classic View
  4. Click the System button
  5. Select the Advanced tab
  6. Click the Environment Variables button
  7. Click the New button to create a CLASSPATH or the Edit button to edit an existing CLASSPATH
  8. Enter CLASSPATH as the variable name
  9. Enter the list of directories or jar files in your CLASSPATH as the variable value, using a semicolon to separate entries in your list
  10. Click OK
  11. Click OK
  12. Click OK