Java Reference
In-Depth Information
2.
Any packages or JAR files that are located within the extension dir-
ectory of the JDK.
3.
Packages, classes, JAR files, and libraries that are loaded somewhere
on the specified class path.
You may need to access more than one directory or JAR file for an application.
This could be the case if your dependencies are located in more than one location. To
do so, simply use the delimiter for your operating system ( ; or : ) as a separator
between the locations specified by the CLASSPATH variable. Following is an example
of specifying multiple JAR files in the CLASSPATH environment variable on Unix and
Linux systems:
export CLASSPATH=/JAVA_DEV/some-jar.jar:/JAVA_LIB/
myjar.jar
Alternatively, you can specify the class path via a command-line option:
javac -classpath /JAVA_DEV/some-jar.jar:/JAVA_LIB/
myjar.jar
When loading the resources for a Java application, the JVM loads all the classes
and packages that are specified in the first location, followed by the second, and so on.
This is important because the order of loading may make a difference in some in-
stances.
Note JAR files are used to package applications and Java libraries into a distribut-
able format. If you have not packaged your application in that manner, you may simply
specify the directory or directories in which your .class files reside.
Sometimes you'll want to include all JAR files within a specified directory. Do that
by specifying the wildcard character ( * ) after the directory containing the files. For ex-
ample:
javac -classpath /JAVA_DEV/*:/JAVA_LIB/myjar.jar
Specifying a wildcard will tell the JVM that it should be loading JAR files only. It
will not load class files that are located in a directory specified with the wildcard char-
Search WWH ::




Custom Search