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


C:\Program Files (x86)\Java

There should be a subdirectory like

C:\Program Files\Java\jre6


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.


  1. Ravindra April 28th

    Comment Arrow


    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” ?


  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!

  13. LuZ January 19th

    Comment Arrow

    Thaaaaank youuuu!! In my case it asked for the jdk instead of jre 🙂

  14. Felipe January 20th

    Comment Arrow

    Thank you very much! “C:\Program Files\Java\jre7 worked great”

  15. Mike January 31st

    Comment Arrow

    Thanks for the help!

  16. mohamed February 8th

    Comment Arrow

    thanks a lot

  17. Denish March 7th

    Comment Arrow

    you are absolutely right. thanks

  18. Nick March 11th

    Comment Arrow

    this was th address that worked for me
    win 8.1
    C:\Program Files\Java\jdk1.8.0_25\jre
    thanxx 🙂

  19. Felix Kemboi April 16th

    Comment Arrow


  20. a corporate slave September 4th

    Comment Arrow

    thanks man!

  21. Mahmoud Sami September 17th

    Comment Arrow

    Great! Thanks.

  22. KarSho February 5th

    Comment Arrow

    Thanks Bro

  23. KarSho February 22nd

    Comment Arrow


  24. Alex March 13th

    Comment Arrow

    Thanks a lot

  25. varinder March 29th

    Comment Arrow

    thanks C:\Program Files\Java\jre7 working

  26. abdellah April 2nd

    Comment Arrow

    thnk u

  27. DiegoM July 29th

    Comment Arrow

    to … to get around the problem of the spaces in the windows directory path, that some tools may not cope with…
    cd C:\
    dir /X Prog*.*
    You get the dir list with the old not-8dot3 names:
    PROGRA~1 Program Files
    PROGRA~2 Program Files (x86)
    Use such names instead of the long dir. names.

  28. asad July 30th

    Comment Arrow

    Thanks alott! it was easy and helpful

Add Yours

  • Author Avatar


Comment Arrow

About Author


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.