Java environment variables in windows

As a followup to my post about how to install Java, i want to do a bit of explaining about how to set up environment variables in windows. it’s pretty simple, but there are a lot of choices, so just doing the correct path first is the easiest.

we will be creating the Java_Home variable, then adding it to the path.

In the past, i have been confused by the ‘home’ directory vs the bin directory. the ‘home’ is the entire installation location. the ‘bin’ is where we need to set the path to.

this will be instructions for windows 10.

  1. from the Windows search, you can type “edit the system environment variables” and it will bring you to the correct control panel page.
    • the page is System Properties –> Advanced
    • you will likely need to type in your admin user/pass here.
  2. at the very bottom of the Advanced tab, there is a button for “Environment Variables…” click into this.
  3. All the settings need to be in the “System Variables” section, not the user variables.
  4. click ‘New…”.
    • Name will be “JAVA_HOME”
    • Value will be your install directory, and in my case as an example: “C:\Program Files\Java\java-se-8u41-ri”
    • make sure it does not include \bin at the end.
  5. Now select the “Path” variable from the system variables list, and click “Edit…”
  6. click “New” within this pop-up of ‘Edit Environment variable”.
    • here we can use the home variable we just created, and add the bin subdirectory. so we type: “%JAVA_HOME%\bin”
  7. click OK, and then OK again to save/close the settings, and then OK again on the system properties and we’re done!

After it’s complete, you may want to restart your terminal to apply the new settings.

Leave a Reply

Your email address will not be published. Required fields are marked *