javapath-variables

How can I set the PATH variable for javac so I can manually compile my .java works?


Here's the address on my drive:

C:\Program Files\Java\jdk1.6.0_18\bin

How would I go about setting the path variable so I can go in command window (windowskey+r "cmd") and be able to type things like:

javac TestApp.java

I'm using Windows 7 Professional.


Solution

  • Typing the SET PATH command into the command shell every time you fire it up could get old for you pretty fast. Three alternatives:

    1. Run javac from a batch (.CMD) file. Then you can just put the SET PATH into that file before your javac execution. Or you could do without the SET PATH if you simply code the explicit path to javac.exe
    2. Set your enhanced, improved PATH in the "environment variables" configuration of your system.
    3. In the long run you'll want to automate your Java compiling with Ant. But that will require yet another extension to PATH first, which brings us back to (1) and (2).