PATH & CLASSPATH
Home ] Up ] Sun's Java Tools ] [ PATH & CLASSPATH ] Filetypes ] Using the Bare SDK ]

 

 

Easily the most troublesome areas you'll encounter while developing in Java are PATH and (more likely) CLASSPATH problems.

PATH

  • Set the PATH environment variable to include the directory containing the Java SDK tools (the Java SDK's /bin subdirectory).

CLASSPATH

  • Set the CLASSPATH environment variable to tell the various Java tools where to look for user-defined classes.
  • The entries should be directories or ZIP files that contain the classes.
  • On UNIX (colon (:)-separated):
setenv CLASSPATH .:/home/bryan/classes:/usr/local/javatools/classes.zip
  • On Windows (semicolon (;)-separated):
set CLASSPATH=.;C:\bryan\classes;D:\local\javatools\classes.zip
  • Can specify an explicit class path to any of the Java utilities:

    java, javac, javadoc, javah, and javap:

-classpath path
  • Setting up CLASSPATH is often critical to getting things to work at all!
Note that if you use a Java IDE, it often removes most of the difficulties dealing with PATH and CLASSPATH.  That alone is a good reason to use one!

 

This page was last modified on 02 October, 2007