Java Language The Classpath Classpath path syntax


The classpath is a sequence of entries which are directory pathnames, JAR or ZIP file pathnames, or JAR / ZIP wildcard specifications.

  • For a classpath specified on the command line (e.g. -classpath) or as an environment variable, the entries must be separated with ; (semicolon) characters on Windows, or : (colon) characters on other platforms (Linux, UNIX, MacOSX and so on).

  • For the Class-Path element in a JAR file's MANIFEST.MF, use a single space to separate the entries.

Sometimes it is necessary to embed a space in a classpath entry

  • When the classpath is specified on the command line, it is simply a matter of using the appropriate shell quoting. For example:

    export CLASSPATH="/home/user/My JAR Files/foo.jar:second.jar"

    (The details may depend on the command shell that you use.)

  • When the classpath is specified in a JAR file's a "MANIFEST.MF" file, URL encoding must be used.

     Class-Path: /home/user/My%20JAR%20Files/foo.jar second.jar