How to Install the JDK on Windows 10

Download the free Microsoft Build of OpenJDK installer for Windows, run it, and turn on JAVA_HOME if your tools need it. Then open Command Prompt and type java -version to check that it works.

Applies to: Windows 10 (64-bit). Keep in mind that Windows 10 support ended on October 14, 2025. Security updates now come only through the Extended Security Updates program, which stops on October 12, 2027.

Pick a version

Choose a long-term support (LTS) version. Microsoft offers OpenJDK 25, 21, 17 and 11. If a class or app asks for a certain version, install that one. Otherwise, pick the newest. If you no longer need an IDE you installed for an old JDK, see how to uninstall Eclipse IDE on Windows 10.

Install with the installer

  1. Go to Microsoft Learn’s Download the Microsoft Build of OpenJDK page.
  2. Under your version, find Windows and x64, and download the .exe file.
  3. Double-click the file to start the installer.
  4. On the options page, keep the option that adds Java to your PATH turned on. Turn on the JAVA_HOME option too if you’ll use build tools like Maven or Gradle.
OpenJDK setup options with the PATH and JAVA_HOME options checked and the Next button
Turn on the JAVA_HOME option (1), then select Next (2).
  1. Select Next, then Install, and select Yes if Windows asks for permission.

Or install with winget

If you have winget, open Command Prompt and type:

winget install Microsoft.OpenJDK.25

Change 25 to 21, 17 or 11 for another version.

Check that it works

  1. Close any Command Prompt windows, then open a new Command Prompt.
  2. Type java -version and press Enter. You should see the version and “Microsoft”.
  3. Type javac -version to check the compiler.
Command Prompt showing java -version and javac -version output for the Microsoft Build of OpenJDK
Check Java (1) and the compiler (2).

If you see ‘java’ is not recognized, the folder isn’t on your PATH. Add it as shown below, or read more about setting environment variables in Windows 10.

Set JAVA_HOME yourself

If you skipped the JAVA_HOME option, or a tool still can’t find Java:

  1. Select Start, type environment variables, and open Edit the system environment variables. Select Environment Variables.
  2. Under System variables, select New. Name it JAVA_HOME and set the value to the JDK folder, such as C:\Program Files\Microsoft\jdk-21.0.12.1-hotspot. Check the exact folder name in File Explorer.
  3. Select Path, then Edit > New, and add %JAVA_HOME%\bin.
  4. Select OK on each window, then open a new Command Prompt and type echo %JAVA_HOME%.

Run a quick test program

Save this as Hello.java in Notepad:

public class Hello { public static void main(String[] a) { System.out.println("Hello, Java!"); } }

In Command Prompt, go to that folder and type java Hello.java. Java compiles and runs it in one step, and prints Hello, Java!

Update or remove the JDK

  • Update: run winget upgrade Microsoft.OpenJDK.21 with your version number, or download and run the newer installer.
  • Remove: go to Settings > Apps > Apps & features, select Microsoft Build of OpenJDK, and select Uninstall.

If Java doesn’t work

  • The wrong version shows: another Java is earlier on your PATH. Type where java to list every copy, then remove the old one or move the new folder higher in Path.
  • ‘javac’ is not recognized: you may have only a Java runtime, not the JDK. Install the JDK, then open a new Command Prompt.
  • A tool says JAVA_HOME is wrong: make sure it points to the JDK folder itself, not its bin folder.

Frequently asked questions

Is the JDK the same as Java?

The JDK includes Java itself, so it runs Java programs too. It also adds tools like javac for building them. Java 21 or 25 from this installer also meets the requirement when you install SonarQube in Windows 10 for code analysis.

Can I have two versions installed?

Yes. Each version installs in its own folder. PATH and JAVA_HOME decide which one runs, so point them at the version you want.

Is the Microsoft Build of OpenJDK free?

Yes. It’s a free, open-source build of Java that Microsoft supports, and you can use it for personal and work projects.

Do I have to remove the old version before I update?

No. A newer update of the same version, such as 21.0.11 to 21.0.12, replaces the old one. Different versions, such as 17 and 21, install side by side.

Are the steps the same on Windows 11?

Yes. The installer, winget command and JAVA_HOME steps are the same on Windows 11.

With the JDK in place you can also open a JAR file on Windows 10, switch between Java versions, or install JMeter on Windows 10.

Every installer option is listed in Install the Microsoft Build of OpenJDK.