O'Reilly logo

Java Garage by Eben Hewitt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required