New to Java? We'll help you get started with our revised beginner's tutorial, or our free online textbook.

Get the latest Java books
h t t p : / /w w w . j a v a c o f f e e b r e a k . c o m /

Java Coffee Break


Learning Java

Author Profiles
Talk Java!

Using Java

Discuss Java

Looking for Java resources? Check out the Java Coffee Break directory!

Getting started with Java

"A beginner's guide to Java programming"

Setting up environmental variables for JDK

Under Windows, you set environmental variables by modifying the autoexec.bat file, located in the root directory of your hard-drive. This batch file is executed on startup; modifications to this file will not take effect until you run it, or reboot.

Tip Remember to reboot! I can't stress this enough. Many readers make the changes, forget to reboot, and wonder why JDK doesn't work properly.

Modifying autoexec.bat

You'll need to edit the autoexec.bat file with a simple text editor. Open it up, and add a path statement pointing to the /bin/ directory under your JDK installation directory. 

Tip Use a simple text editor, like notepad or the DOS command 'edit'.

For example, if I'd installed my JDK to c:\jdk1.3\, I'd want to point the path statement to c:\jdk1.3\bin\. However, you must also be careful not to overwrite existing path statements set for other software packages. To prevent this, use the following statement (modifying directory for your installation location)
set path=%path%;c:\jdk1.3\bin\

Next, you need to set the classpath to include the current directory. The classpath helps JDK locate Java software (class files) that are installed on your machine. Some versions of JDK don't require this, but some of the tools that ship with JDK do require it, so it's best to set this environmental variable up properly.

set classpath=%classpath%;.\

Tip Sometimes, you may run out of environmental space, and see the message "Too many parameters" on boot up. If this happens, add the following line to config.sys (located in the root directory)
shell=c:\ /p /e:32000

That done, reboot and you'll be ready to start writing your first Java application.


Next : Writing your first Java application

Back to main

Copyright 1998, 1999, 2000 David Reilly

Privacy | Legal | Linking | Advertise!

Last updated: Monday, June 05, 2006