If you’re a Java programmer you’d know what a pain it is to compile the program andrun it. Especially if your working directory is in some other place, than where you have installed JDK. There is a simple workaround for this problem, setting a PATHvariable. So instead of compiling a program with something like C:\Program Files\Java\jdk1.6.0_20\bin\javac MyProgram.java you’d only need to use the command javac MyProgram.java.
Just follow these steps:
- First right-click on your My Computer icon on your Desktop and click on Properties. Alternatively you could just press the Windows Key+Pause Break Key.
- Now in the new window that opened, click on the Advanced tab.
- Now click on Environment Variables.
- In the new Window that opened, click on New.
- In the Variable Name field enter PATH and in the Variable Value enter the path of your JDK bin folder. (For eg. C:\Program Files\Java\jdk1.6.0_20\bin)
- Now press OK in the window that remains open, you’ll have to do it thrice.
That’s it. Now if you try to compile your program from anywhere else than your JDK\bin directory, you can do so successfully.