Java Language Installing Java (Standard Edition) Setting %PATH% and %JAVA_HOME% after installing on Windows



  • An Oracle JDK has been installed.
  • The JDK was installed to the default directory.

Setup steps

  1. Open Windows Explorer.

  2. In the navigation pane on the left right click on This PC (or Computer for older Windows versions). There is a shorter way without using the explorer in actual Windows versions: Just press Win+Pause

  3. In the newly opened Control Panel window, left click Advanced System Settings which should be in the top left corner. This will open the System Properties window.
    enter image description here

    Alternatively, type SystemPropertiesAdvanced (case insensitive) in the Run (Win+R), and hit Enter.

  4. In the Advanced tab of System Properties select the Environment Variables... button in the lower right corner of the window.

  5. Add a New System Variable by clicking the New... button in System Variables with the name JAVA_HOME and whose value is the path to the directory where the JDK was installed. After entering these values, press OK.

    JAVA_HOME Environment Variable

  6. Scroll down the list of System Variables and select the Path variable.

  7. CAUTION: Windows relies on Path to find important programs. If any or all of it is removed, Windows may not be able to function properly. It must be modified to allow Windows to run the JDK. With this in mind ,click the "Edit..." button with the Path variable selected. Add %JAVA_HOME%\bin; to the beginning of the Path variable.

It is better to append at the begining of the line because Oracle's software used to register their own version of Java in Path - This will cause your version to be ignored if it occurs after Oracle's declaration.

Check your work

  1. Open the command prompt by clicking Start then typing cmd and pressing Enter.
  2. Enter javac -version into the prompt. If it was successful, then the version of the JDK will be printed to the screen.

Note: If you have to try again, close the prompt before checking your work. This will force windows to get the new version of Path.