Java Language The Classpath Classpath path syntax

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

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
    


Got any Java Language Question?