| CSCI A201/A597The 'round the PATH Hack Spring 2000 |
The installation process eventually copies all the necessary files in a directory
This directory contains several sub-directories, one of them beingc:\jdk1.2.2
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:
it will work.c:\jdk1.2.2\bin\javac Hello.java
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:
One line. Thec:\jdk1.2.2\bin\javac %1
% 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:
Just like the name of the file.c:\jdk1.2.2\bin\java %1
Now everytime you run these batch files you will actually start
JDK's javac and java.
If you need help please let me know.