← All posts

How to JAVA_HOME in Windows 10

If you write Java, sooner or later you need to set JAVA_HOME. It’s one of those basic things every Java developer ends up doing. Let me walk you through it on Windows 10, one click at a time.

Open the environment variables

Search for path and open the Edit the system environment variables app.

Windows search showing Edit the system environment variables

Then click the Environment Variables… button.

System Properties window with the Environment Variables button

Create the JAVA_HOME variable

In the System variables section, click New….

Environment Variables window with the New button under System variables

Now fill in the details:

New System Variable dialog

  • Variable name: JAVA_HOME
  • Variable value: click Browse Directory… and pick your Java Development Kit (JDK) folder.
  • Click OK.

Add JAVA_HOME to your Path

Back in the list, select Path and click Edit….

Path selected in the System variables list

The Edit environment variable window pops up.

Edit environment variable window

Click New, type %JAVA_HOME%\bin, and click OK. Then click OK again to close the Environment Variables window, and one more OK to close System Properties.

Check that JAVA_HOME is set

Search for cmd and open the Command Prompt app.

Windows search showing Command Prompt

Type echo %JAVA_HOME% and hit Enter. It should print the JDK path you picked earlier.

Command Prompt printing the JAVA_HOME path

Check java and javac too

While you’re here, let’s confirm Java and the Java compiler work.

Type java -version and hit Enter, then javac -version and hit Enter. You’ll see the Java version, build number, and compiler version.

Command Prompt printing java and javac versions

That’s it! Your computer is ready for Java. Let’s rock!