Skip to content

Instantly share code, notes, and snippets.

@Munksgaard
Created November 22, 2012 10:57
Show Gist options
  • Save Munksgaard/4130555 to your computer and use it in GitHub Desktop.
Save Munksgaard/4130555 to your computer and use it in GitHub Desktop.
How to add Java executables to your PATH
This guide is intended to help you set up your PATH in Windows for Java executables. This will enable you to run the Java executables, java, javac and others, from your commandline (cmd.exe). It is assumed that you have installed the Java 7 JDK already
First find the location of the Java executables. These are usually located in something like
C:\Program Files\Java\java-1.7.0-jdk\bin\
Now, how you proceed from here depends on your version of Windows:
For Windows 7
- Select Computer from the Start menu
- Choose System Properties from the context menu
- Click Advanced system settings > Advanced tab
- Click on Environment Variables, under System Variables, find PATH, and click on it.
- In the Edit windows, modify PATH by adding the location of the Java executables
found above to the end of the value for PATH (seperated by a semicolon).
If you do not have the item PATH, you may select to add a new variable and add PATH
as the name and the location of the executables as the value.
Also remember that if the PATH variable includes any paths with spaces in them,
the whole variable needs to be enclosed in double quotes.
- Reopen Command prompt window, and run your java code.
For Windows XP
- Start -> Control Panel -> System -> Advanced
- Click on Environment Variables, under System Variables, find PATH, and click on it.
- In the Edit windows, modify PATH by adding the location of the Java executables
found above to the end of the value for PATH (seperated by a semicolon).
If you do not have the item PATH, you may select to add a new variable and add PATH
as the name and the location of the executables as the value.
Also remember that if the PATH variable includes any paths with spaces in them,
the whole variable needs to be enclosed in double quotes.
- Close the window.
- Reopen Command prompt window, and run your java code.
For Windows Vista
- Right click My Computer icon
- Choose Properties from the context menu
- Click Advanced tab (Advanced system settings link in Vista)
- In the Edit windows, modify PATH by adding the location of the Java executables
found above to the end of the value for PATH (seperated by a semicolon).
If you do not have the item PATH, you may select to add a new variable and add PATH
as the name and the location of the executables as the value.
Also remember that if the PATH variable includes any paths with spaces in them,
the whole variable needs to be enclosed in double quotes.
- Reopen Command prompt window, and run your java code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment