In addition to Java applications (using the
java
command), this parameter is also applicable to other JDK utilities, such as javac
, javadoc
, and others.There are two main ways to set the classpath: through the OS environment variable
CLASSPATH
, and through the command line argument -cp
(or its synonym -classpath
). The latter is preferable because it allows different values for different applications. The default value is the current directory.The parameter includes paths to JAR files and root directories with packages. Paths are separated by
:
in the command line parameter or ;
in the environment variable. To include all files in a directory, the *
wildcard can be used at the end of the path.If the application is launched as a JAR file (
java -jar
), the classpath should be specified in its manifest.