views:

350

answers:

2

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.

+2  A: 

That would be:

set PATH="%PATH%;C:\Program Files\Java\jdk1.6.0_18\bin"

You can also append ;C:\Program Files\Java\jdk1.6.0_18\bin to the PATH in the user environment dialog. That would allow you to use javac and other java tools directly form any cmd shell without setting the path first. The user environment dialog used to be somewhere in the system properties in XP, I have no idea where it is in Windows 7.

x4u
Um... where do I run this code. What do I do with it.
Sergio Tapia
In the command window, just before you type `javac`.
Carl Smotricz
you just copy paste it into your cmd window an press enter.
x4u
+5  A: 

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. Here's a document all about this for Windows XP: http://vlaurie.com/computers2/Articles/environment.htm
    and... found it! Here's an even nicer looking one for Windows 7: http://www.itechtalk.com/thread3595.html
  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).
Carl Smotricz