Setting the CLASSPATH

     

Sometimes, your programs will reference external libraries that are custom libraries of your own, or a third-party library, or a package in the Java 2 Enterprise Edition. Use the set command to set the classpath environment variable. The classpath tells the Java Virtual Machine where to find necessary class libraries. These libraries can be directories, .jar files (most commonly), .class files, or even .zip files. The path to a .jar or .zip file ends with the file name; the path to a .class file ends with the directory name .

In Windows

First, open a command prompt. Then type

 

 set CLASSPATH=.;C:\java\MyClasses;C:\java\My.jar 

Note that setting the classpath in this manner will only sustain the variable for the current command prompt session. Closing the prompt and opening a new one resets the variable.

In Linux/UNIX

In the bash shell you can type the following to set the classpath:

 

 export CLASSPATH=/home/someapp/MyClasses.jar: $CLASSPATH 



Java Garage
Java Garage
ISBN: 0321246233
EAN: 2147483647
Year: 2006
Pages: 228
Authors: Eben Hewitt

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net