Java Reference
In-Depth Information
1.
Use
CD
to open the folder that contains the Java interpreter (
java.exe
).
2.
Enter the command
CD ..
.
3.
Enter the command
CD lib
.
The
lib
folder normally contains the right copy of
tools.jar
.
When you know the correct location, create a blank line at the bottom of the
AUTOEXEC.BAT
file and add the following:
SET CLASSPATH=%CLASSPATH%;.;
rightlocation
For example, if
tools.jar
file is in the
c:\Program Files\Java\jdk1.6.0\lib
folder,
the following line should be added at the bottom of
AUTOEXEC.BAT
:
SET CLASSPATH=%CLASSPATH%;.;c:\”Program Files”\Java\jdk1.6.0\lib\tools.jar
After making changes to
AUTOEXEC.BAT
, save the file and reboot your computer. After
this is done, try to compile and run the
HelloUser
sample program again. You should be
able to accomplish this after the
CLASSPATH
variable has been set up correctly
Setting the
Classpath
on Windows NT, XP, 2000 or
2003
On a Windows NT, XP, 2000, or 2003 system, you also configure the
Classpath
variable
using the Environment Variables dialog box.
To open it
1.
Right-click the My Computer icon on your desktop or Start menu and choose
Properties. The System Properties dialog box opens.
2.
Click the Advanced tab to bring it to the front.
3.
Click the Environment Variables button. The Environment Variables dialog box
opens (Figure A.13).
If your system has a
Classpath
variable, it will probably be one of the system variables.
Your system may not a
Classpath variable set
—the kit can normally find class files
without the variable.
However, if your system has a
Classpath
, it must be set up with at least two things: a
reference to the current folder (a period) and a reference to a file that contains the Java
class library,
tools.jar
.