Sunday 27 May 2012

Getting ‘javac’ command to work in Windows Vista


One of the main issues with using java is if you want to do anything complex and are using Windows instead of Linux, you may need to set windows to allow you to use the javac command in the command line window.

Doing this is really easy if you know what to do, and a pain in the butt if your doing it for the first time.

Instructions

In windows press start->run.

Type in "explorer"



Right click on the 'Computer' and click 'properties'.



Click Advanced System Settings.



In the window that pops up, navigate to the 'advanced tab' and click the 'environment variables' button at the bottom.



In the 'System variables' section at the bottom, scroll down untill you see the 'Path' variable, then click it.



Now that the 'Path' variable is highlighted, click the 'edit' button at the bottom.

  • Important: Whatever you do, DONT delete the text that is already the section that pops up.


The first step to do is make sure there is a semicolon ( ; ) at the very end of the text, which there probably isn't, so add one in. This is to separate the rest of the text from what you are about to put in.

  • Note: A semicolon is used to separate all paths, so if you were to add another path in later, you would need another semicolon at the end of the text you are about to put in.


Copy and paste the path to your java jdk 'bin' directory here. It must be the java 'jdk' bin folder and not 'jre' or anything else. The java bin directory should contain the javac.exe file. For example, my java directory containing the 'javac' command that I want to use is located at: 'C:\Program Files\Java\jdk1.6.0_11\bin'

You will most probably have to change the part after 'Java\' and before '\bin' to match your jdk.

After you have done this click the 'ok' button, and then the ok button at the bottom of the Environment Variables pane.

You are finished!



Troubleshooting
  • Note: An easy way to find what you should put in as the address is to open up another explorer pane,
    (start->run->'explorer') and navigate to c:/program files/java and then click the folder with ' jdk ' in the name. Then click the bin directory and click the address bar at the top to highlight the address and click copy. Then you can just paste the entire address directly into the path file.






  • Make sure your address does not end in '\' or ';' since mine doesnt and it works. You will have to add a ';' to the end later if you want to add another path.
  • Make sure to close any command panes and open up a new one before you try and use the javac command, as the variable may not be set correctly in ones that were already open before you made the changes.

If you are still having problems, please comment.

No comments:

Post a Comment