Setting PATH and CLASSPATH

Determining the current values of PATH and CLASSPATH

Unix

Type these commands in a command window:
echo $PATH
echo $CLASSPATH

If you get a blank command line in response to either of these, then that particular variable has no value (it has not yet been set).

Windows

Type these commands in a command window:
echo %PATH%
echo %CLASSPATH%

If you get the message "echo is on" for either of these, then that particular variable has no value (it has not yet been set).

Changing PATH and CLASSPATH

Windows 98

First, try the instructions for "Other Versions of Windows." If you are able to set PATH via the System window, great! Otherwise, you will need to modify a line of text in the c:\autoexec.bat file and restart your computer.

  1. Start Notepad (Start > Program Files > Accessories > Notepad)

  2. Open c:\autoexec.bat (File > Open, change to the c: folder and look for and open autoexec.bat. If you don't find one, create one.)

  3. You might find one or more than one line that starts with "set path". Look for one.

  4. If you do not find any lines starting with "set path", then add this new line to the end of the autoexec.bat file:
    set path=c:\j2sdk1.4.1_01\bin
    
    (This assumes that you really do have such a folder after you installed Java SDK 1.4. Please verify as needed.)

  5. If you already have one or more lines starting with "set path", go to the last one. If it does not currently include "c:\j2sdk1.4.1_01\bin", then add a semicolon to the righthand end of the "set path" expression and then add this:
    c:\j2sdk1.4.1_01\bin
    
  6. Save the changes to autoexec.bat.

  7. You might find one or more than on line that starts with "set classpath". Look for one.

  8. If you do not find any lines starting with "set classpath", exit Notepad and any other programs and restart your computer. Try the java and javac commands again to see if they work now. You can ignore the remaining instructions below.

  9. If you already have one or more lines starting with "set classpath", go to the last one. Add this to the righthand end of the "set classpath" expression:
    ;.
    
  10. Save the changes to autoexec.bat, exit Notepad and any other programs and restart your computer. Try the java and javac commands again.

Other versions of Windows

  1. Start your System panel (Start > Settings > Control Panel > System).

  2. If you see Advanced or Environment, click those. (If you do not, follow the autoexec.bat instructions for Windows 95 users, above.)

    There are two windows on this panel: System variables and User variables. Check whether you have a Set button or a New button.

  3. If you see a Set button:
    • Do not click the Set button.
    • Click on ANY item in the User variables list. The Variable and Value fields are then filled in with whatever item you clicked.
    • Replace the expression in the Variable field with the single word PATH.
    • Replace the expression in the Value field with the following (where you should use replace "j2sdk1.4.1_01" with whatever directory name is correct for your installation of java):
      %path%;c:\j2sdk1.4.1_01\bin
      
    • Click both Set and Apply, in that order.
    • Now replace the expression in the Variable field with the single word CLASSPATH.
    • Replace the expression in the Value field with this:
      %classpath%;.
      
    • Click both Set and Apply, in that order.
    • Exit all windows and programs, especially any command prompt window. Try the java and javac commands again to see if they work now. If they do not, restart your computer and try the java and javac commands again.

  4. If you see a New button and not a Set button:
    • Click New.
    • In the Name field, type PATH.
    • In the Value field, type the following (where you should use replace "j2sdk1.4.1_01" with whatever directory name is correct for your installation of java):
      %path%;c:\j2sdk1.4.1_01\bin
      
    • Click OK to complete that variable.
    • Click in the User variables window.
    • Click New and create a variable named CLASSPATH with the following value:
      %classpath%;.
      
    • Click OK to complete that variable.
    • Exit all windows and programs, especially any command prompt window. Try the java and javac commands again to see if they work now. If they do not, restart your computer and try the java and javac commands again.

John E. Darrow
Other John Links