The Java(TM) virtual machine uses the Java™ classpath to find classes during runtime. Java commands and tools also use the classpath to locate classes. The default system classpath, the CLASSPATH environment variable, and the classpath command parameter all determine what directories are searched when looking for a particular class.
In the Java 2 Software Development Kit (J2SDK), Standard Edition, the java.ext.dirs property determines the classpath for the extensions that are loaded. See Install extensions for the IBM® Developer Kit for Java for more information.
The default bootstrap classpath is system-defined, and you should not change it. On your server, the default bootstrap classpath specifies where to find the classes that are part of the IBM Developer Kit, the Native Abstract Window Toolkit (NAWT), and other system classes.
To find any other classes on the system, you must specify the classpath to search by using the CLASSPATH environment variable or the classpath parameter. The classpath parameter that is used on a tool or command overrides the value that is specified in the CLASSPATH environment variable.
You can work with the CLASSPATH environment variable using the Work with Environment Variable (WRKENVVAR) command. From the WRKENVVAR display, you can add or change the CLASSPATH environment variable. The Add Environment Variable (ADDENVVAR) command and Change Environment Variable (CHGENVVAR) command either add or change the CLASSPATH environment variable.
The value of the CLASSPATH environment variable is a list of path names, separated by colons (:), which are searched to find a particular class. A path name is a sequence of zero or more directory names. These directory names are followed by the name of the directory, the ZIP file, or the JAR file that is to be searched in the integrated file system. The components of the path name are separated by the slash (/) character. Use a period (.) to indicate the current working directory.
You can set the CLASSPATH variable in the Qshell environment by using the export utility that is available using the Qshell Interpreter.
These commands add the CLASSPATH variable to your Qshell environment and set it to the value " .:/myclasses.zip:/Product/classes."
export -s CLASSPATH=.:/myclasses.zip:/Product/classes
ADDENVVAR ENVVAR(CLASSPATH) VALUE(".:/myclasses.zip:/Product/classes")
The J2SDK searches the bootstrap classpath first, then the extension directories, then the classpath. The search order for J2SDK, using the previous example above, is:
When entering the Qshell environment, the CLASSPATH variable is set to the environment variable. The classpath parameter specifies a list of path names. It has the same syntax as the CLASSPATH environment variable. A classpath parameter is available on these tools and commands:
For more information about these commands, see Commands and tools for the IBM Developer Kit for Java. If you use the classpath parameter with any of these command or tools, it ignores the CLASSPATH environment variable.
You can override the CLASSPATH environment variable by using the java.class.path property. You can change the java.class.path property, as well as other properties, by using the SystemDefault.properties file. The values in the SystemDefault.properties files override the CLASSPATH environment variable. For information on the SystemDefault.properties file, see the SystemDefault.properties file.
In J2SDK, the -Xbootclasspath option also affects what directories the system searches when looking for classes. Using -Xbootclasspath/a:path appends path to the default bootstrap classpath, /p:path prepends path to the bootstrap classpath, and :path replaces the bootstrap classpath with path.
See Java system properties for information about how to determine the environment in which Java programs run.
For more information, see the Program and CL Command APIs or the Integrated file system.