Setting the CLASSPATH
Environment Variable
on the Windows Platform
To develop and test applications written in the Java
TM programming language using the Windows environment, you must set a path and CLASSPATH
so programs can locate necessary classes and .jar
files.
Open the autoexec.bat
file (located in your root (\) directory) in a text editor, or type sysedit
in Run from the Start button.
If you're only going to be using the J2SE, then the following line is all that's needed:
PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;C:\JDK\BIN;
The example above assumes C is the drive where the development kit has been installed and that the directory name is JDK.
If you may be using other development tools in addition to J2SE, then follow the instuctrions below. Also note how other tools, such as the JavaTM Servlet Web Development Kit and the MySQL database driver can be included in the CLASSPATH
. These may or may not apply to your needs.
Enter the following to set a CLASSPATH
:
SET PATH=%PATH%;%JAVAHOME%\BIN
PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;C:\JDK\BIN;
SET CLASSPATH=.;C:\jdk\lib\tools.jar;
C:\jswdk\lib\servlet.jar;
C:\mm.mysql.jdbc-1.2b;%CLASSPATH%
Note: To ensure programs locate the complier and APIs, keep the SET CLASSPATH
command on one line.
Save the file and close the editor. To force these settings to take place, simply restart your computer, or open an MS-DOS window and type autoexec.bat
.