Setting JAVA_HOME Variable in Windows

In this example we will set the JAVA_HOME variable in Windows. The JAVA_HOME variable is used by applications to find the Java Development Kit installation.

Find JDK Installation Directory

First you need to know the installation path for the Java Development Kit.

Open the default installation path for the Java Development Kit

C:\Program Files\Java

or

C:\Program Files (x86)\Java

There should be a subdirectory like

C:\Program Files\Java\jre6

or

C:\Program Files (x86)\Java\jre6

Set the JAVA_HOME Variable

Once you have the JDK installation path:

  • Right-click the My Computer icon on your desktop and select Properties.
  • Click the Advanced tab.
  • Click the Environment Variables button.
  • Under System Variables, click New.
  • Enter the variable name as JAVA_HOME.
  • Enter the variable value (one of the paths mentioned above) as the installation path for the Java Development Kit.
  • Click OK.
  • Click Apply Changes.

You might need to restart windows.



Comments

  1. Ravindra April 28th

    Comment Arrow

    Hi,

    This is a very decent article for the new developers for JAVA


  2. dude503 July 1st

    Comment Arrow

    Your example above is defining the location of the JRE not the JDK and this may cause failure by some tools.

    How would you define the variable, to get around the problem of the spaces in the windows directory path, that some tools may not cope with?

    e.g. on Windows 7, the 32-bit JDK could be
    C:\Program Files (x86)\Java\jdk1.7.0

    so would you define that as
    “C:\Program Files (x86)\Java\jdk1.7.0″ ?

    Thanks.


  3. Thinkx July 8th

    Comment Arrow

    Thanx. This was help me lot.. :)


  4. babanna August 23rd

    Comment Arrow

    thanks. Very simple steps and very helpful…


  5. specky September 16th

    Comment Arrow

    Your Message…thanks very much buddy


  6. fahad November 24th

    Comment Arrow

    not working for me :( ..
    i have windows 7 64 bit ..
    i try above solution but no use :( ..
    still unable to use any java tool …
    please help


  7. jeevan November 25th

    Comment Arrow

    what is the sixth step? can you please explain…..


  8. naif March 12th

    Comment Arrow

    best help .. )


  9. chaitanya April 14th

    Comment Arrow

    Thanks it helped


  10. Vittal May 6th

    Comment Arrow

    Many Thanks… it was v helpful


  11. Nargis August 27th

    Comment Arrow

    Thanks,,,very nice steps for beginner …. (Y)


  12. Gary November 5th

    Comment Arrow

    Thanks a lot. C:\Program Files\Java\jre7 worked great!


Add Yours

  • Author Avatar

    YOU


Comment Arrow




About Author

Robert

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning hands down.