'; zhtm += ''; zhtm += '

' + pPage + ''; zhtm += '
'; window.popUpWin.document.write(zhtm); window.popUpWin.document.close(); // Johnny Jackson 4/28/98 } //--> Java 1.2 Unleashed -- Appendix B -- Java Environment Variables

Java 1.2 Unleashed

Previous chapterNext chapterContents

- B -

Java Environment Variables

This appendix describes important environment variables used with the tools of JDK 1.2 and discusses how to set up these variables during JDK 1.2 installation. This appendix is specific to Windows-based operating systems (Windows 95, Windows 98, and Windows NT). For information about the environment variables used by other ports of JDK 1.2, consult the documentation that comes with that port.

Adding the JDK Tools to Your PATH

The JDK 1.2 installation software installs the JDK files in the C:\jdk1.2 directory by default. The JDK 1.2 tools (compiler, debugger, and so on) are installed in the C:\jdk1.2\bin directory by default. To run these tools without having to type in their full path name, add C:\jdk1.2\bin to your PATH variable. The easiest way to do this is to add the following line to your AUTOEXEC.BAT file:


The otherxyour PATH. Windows NT users may also use the System option in the Control Panel to set the PATH variable. If you are using Windows 95, you can also use the following line (in your AUTOEXEC.BAT file) to set your PATH:


%PATH% is used to prepend your existing path to C:\jdk1.2\bin.

NOTE: If you install the JDK in a directory other than C:\jdk1.2, you'll have to adjust your PATH accordingly.

Setting Your CLASSPATH

The CLASSPATH environment variable identifies the location of compiled Java classes. The CLASSPATH is set on Windows 95 and Windows 98 systems by including the following line in the AUTOEXEC.BAT file:


The pathlist is a semicolon-separated list of paths where compiled Java classes are to be found. On Windows NT, the CLASSPATH is set using the System option in the Control Panel.

By default, the JDK tools append the following path list to the CLASSPATH variable:


This tells the tools to look in the current directory (.), and the JAR file C:\jdk1.2\src.jar for compiled Java classes.

If you installed the JDK in a directory other than C:\jdk1.2, the JDK tools will adjust the appended paths to the directory where the JDK was installed.

Many of the extension APIs, such as JavaMail, are distributed as .jar files. To add a .jar file to your CLASSPATH, add the file's full path name. For example, I copied mail.jar to my C:\jdk1.2\lib directory and added mail.jar to my CLASSPATH using the following:

set CLASSPATH=%CLASSPATH%;C:\jdk1.2\lib\mail.jar

The statement appends the mail.jar file to my current CLASSPATH.


The environment variables JDK_HOME and JRE_HOME are environment variables that are used by the HotJava browser. As of version 1.1, HotJava comes with its own copy of the Java runtime environment. If you want HotJava to use another installation of the JDK or JRE, set JDK_HOME or JRE_HOME, as appropriate. For example, adding the following line to your AUTOEXEC.BAT file tells HotJava to use the JDK installed in C:\jdk1.2:

SET JDK_HOME=C:\jdk1.2

If both JDK_HOME and JRE_HOME are set, JDK_HOME is used.

Previous chapterNext chapterContents

© Copyright, Macmillan Computer Publishing. All rights reserved.