CSCI A201/A597

The 'round the PATH Hack

Spring 2000


You've downloaded and installed JDK and you can't follow my instructions to set the PATH environment variable. Here's how you get around that.

The installation process eventually copies all the necessary files in a directory

c:\jdk1.2.2
This directory contains several sub-directories, one of them being bin. The bin directory contains the two programs that we're interested in: javac (the compiler) and java (the interpreter). We need to make sure that these two files are available from anywhere (on disk) in a DOS window.

If instead of using javac you use the full name:

c:\jdk1.2.2\bin\javac Hello.java
it will work.

So the idea is to wrap the name into a batch file with a shorter name that you'd be placing in the PATH (since you don't seem to be able to change the PATH).

Create a file called javac.bat that you place in your PATH. c:\dos is likely to be in your PATH so you can place it there. (Type PATH to see your PATH).

The contents of the file is as follows:

c:\jdk1.2.2\bin\javac %1
One line. The % refers to the command line argument.

(In some sense %1 in a batch file is args[0] in Java).

Create another file java.bat and place it in the same location. The contents of the file differs in only one letter:

c:\jdk1.2.2\bin\java %1
Just like the name of the file.

Now everytime you run these batch files you will actually start JDK's javac and java.

If you need help please let me know.


Last updated: January 25, 2000 by Adrian German