Java Classpath for iSeries(AS400) Tutorial

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.

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 " .:/directory/something.jar:/directory/classes"

This command sets the CLASSPATH variable in the Qshell environment:
export -s CLASSPATH=.:/directory/something.jar:/directory/classes

This command sets the CLASSPATH variable from the command line:
ADDENVVAR ENVVAR(CLASSPATH) VALUE(".:/directory/something.jar:/directory/classes")

Sample CL program to set Java Home and Classpath

RMVENVVAR  ENVVAR(JAVA_HOME)                             
MONMSG     MSGID(CPF0000)                                
RMVENVVAR  ENVVAR(CLASSPATH)                             
MONMSG     MSGID(CPF0000)                                
CD         DIR('/directory1/directory2')                     
ADDENVVAR  ENVVAR(JAVA_HOME) +                           
ADDENVVAR  ENVVAR(CLASSPATH) +                           

No comments:

Post a Comment

NO JUNK, Please try to keep this clean and related to the topic at hand.
Comments are for users to ask questions, collaborate or improve on existing.