Tuesday, January 17, 2012

Set PATH for JDK 7 on Windows 8

You can run the JDK without setting the PATH environment variable, or you can optionally set it so that you can conveniently run the JDK executable files (javac.exe, java.exe, javadoc.exe, and so forth) from any directory without having to type the full path of the command.

To setup PATH in Windows 8:
Run Control Panel in Windows 8's Metro UI


Click More Settings in Control... on the left.


Search "Environment Variables" in Control Panel, and click "Edit the system environment variables".


Click on "Environment Variables..."


Scroll down to highligh and edit path items.


My full path of the bin folder of the JDK is:
C:\Program Files\Java\jdk1.7.0_02\bin

So add ";C:\Program Files\Java\jdk1.7.0_02\bin" in the path string.


Click OK... to finish.

Re-open Windows 8's "cmd" window, now i can start java and javac in anywhere.



Updated@2013-01-17: Set PATH environment variable to JDK on official Windows 8

32 comments:

  1. i removed by mistake the other paths at the variable path while adding C:\Program Files (x86)\Java\jdk1.7.0_09\bin,could it be harmfull for my o.s.?Is there any way to retrieve them?
    anyway thanks for the post!

    ReplyDelete
    Replies
    1. no, some programs that use the path variable wont work though and you will have to look up their paths and add them in again. nothing irreparable. i did it a few times myself

      Delete
    2. how do u recover those paths??

      Delete
  2. I can run java in the cmd but not javac. Where is the probem?
    i don`t have JavaFx 2.0 SDK, it's there?

    ReplyDelete
  3. This worked for me. Thanks !!! =) Exactlt what I needed!
    ~Rahul

    ReplyDelete
  4. after installing jdk and setting path my windows 8 system is not working.. give me some suggestions pls

    ReplyDelete
  5. Can't compile using javac but i can use the java command...any help?

    ReplyDelete
  6. can't compile and run,and getting an error" 'javac' is not recognized an an internal and external command ,operable program and batch file." plz any1 help...?

    ReplyDelete
  7. Brilliant. Works perfectly!
    Thanks a lot. :-)

    ReplyDelete
  8. i did as above but while
    c:\ece>edit cal.java
    i am getting an error : 'edit' is not recognisable

    ReplyDelete
    Replies
    1. If OS is windows 8

      1. Right click on CMD
      2. Chose Options "Run As Administrator"

      Hope this Works''''

      Delete
    2. this worked. Should give Administrator rights. Thanks

      Delete
  9. HOW DO I GET THE PATH I DELETED BACK

    ReplyDelete
  10. for all those who are unable to run javac command...try by putting ";" before c:/..worked for me ..thx

    ReplyDelete
  11. I have done the instructions but neither "java" or "javac" work. I just get told it's not recognised as an internal or external command, operable program or batch file.
    Thanks in advance.

    ReplyDelete
    Replies
    1. 1. open command promt.
      2. with cd command go to your java directory
      3. then try java or javac.
      4. If it is not working then something problem with your installation else try it once again as said in the above article.

      Delete
  12. It's more easier to access the System panel with the shortcut (Windows Key) + Pause with the Desktop Mode.

    Then you go directly to the Advanced Tab

    ReplyDelete
  13. Can you write down the original path? I deleted it by accident and need to know the original one.

    ReplyDelete
  14. I've done everything there and it still doesn't work, plus my path system is weird and different than yours
    HELP...

    ReplyDelete
  15. C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\AMD APP\bin\x86;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\Windows Live\Shared\;C:\Program Files\Java\jdk1.7.0_02\bin

    this is my program thing

    ReplyDelete
  16. can't compile and run,and getting an error" 'javac' is not recognized an an internal and external command ,operable program and batch file." plz any1 help...?

    ReplyDelete
  17. I found this, had the same problem on windows 8 until i tried this: http://stackoverflow.com/questions/7709041/javac-is-not-recognized-as-an-internal-or-external-command-operable-program-or . The answer you're looking for is the one with over 65 votes. :) Happy coding!

    ReplyDelete
  18. Thanks a ton to the author! I was trying this for more than an hour till the time i finally came here and it got solved! :D

    ReplyDelete
  19. ohh its working.thanks a lot.now i can compile easily...thank u again

    ReplyDelete
  20. it worked thanks................

    ReplyDelete
  21. By mistakely i hve deleted the path with values....How can i recover my predefined path in setting...

    ReplyDelete