How to Install Java on Windows 11: JDK, JAVA_HOME, and PATH Setup

To install Java on Windows 11, download the 64-bit Windows installer (.msi or .exe) for a current Java Development Kit (JDK), run it, and accept the defaults. Then open Command Prompt and type java -version to confirm it worked. Good free choices are Oracle JDK from oracle.com, Eclipse Temurin from adoptium.net, and the Microsoft Build of OpenJDK. If you only need Java to run an older program, the Java download on java.com may be what that program expects.

This guide explains which Java to pick, three ways to install it, how to set JAVA_HOME and PATH, and how to fix “java is not recognized” errors.

Which Java should you install?

If you want to… Install
Write or compile Java code, or use tools like Maven, Gradle, or an IDE A JDK, ideally the latest long-term support (LTS) version, such as Java 25 or 21
Run a specific app or game The version that app asks for. Check its website or error message.
Run an older desktop app that asks for “Java 8” Java 8 from java.com, or a Java 8 build from Temurin
Play Minecraft: Java Edition Nothing. The Minecraft Launcher includes the Java it needs.

A JDK includes everything you need to run Java apps as well, so if you’re not sure, a current JDK is a safe choice. Always choose the x64 installer on most PCs, or ARM64 if your PC has an ARM processor, such as a Snapdragon chip.

Method 1: Install a JDK with the Windows installer

  1. Go to the download page for the JDK you chose, such as adoptium.net (Temurin) or oracle.com/java (Oracle JDK).
  2. Choose Windows, x64, and the .msi or .exe installer for the version you want.
  3. Open the downloaded file and click Yes if User Account Control asks for permission.
  4. Follow the prompts. In the Temurin installer, you can turn on Set JAVA_HOME variable and Add to PATH on the custom setup screen, which saves you the steps later in this guide.
  5. Click Install, then Finish.

Oracle JDK is free to use under Oracle’s current license terms, but those terms have changed over the years. If you’re installing Java for a business, check the license first, or use an OpenJDK build like Temurin or Microsoft’s.

Method 2: Install Java with winget

Windows 11 includes winget, a command-line tool that installs apps for you.

  1. Right-click Start and choose Terminal.
  2. Search for available JDKs by typing winget search jdk and pressing Enter.
  3. Find the one you want in the Id column, then install it with winget install --id followed by that ID. For example:
winget install --id EclipseAdoptium.Temurin.25.JDK

Replace the ID with the one you found in step 2, since the exact names and versions change over time.

Method 3: Install Java for running apps (java.com)

  1. Go to java.com and click Download Java.
  2. Run the installer and follow the prompts.

This installs Java 8, which some older desktop programs still require. It isn’t suited to writing modern Java code.

Check that Java is installed

  1. Close any open terminal windows, then open a new Command Prompt or Terminal.
  2. Type java -version and press Enter. You should see the version number.
  3. If you installed a JDK, type javac -version as well. This confirms the compiler is available.

Set JAVA_HOME and PATH

Many developer tools look for a JAVA_HOME environment variable. Some installers set it for you. If echo %JAVA_HOME% in Command Prompt just prints %JAVA_HOME%, set it yourself:

  1. Open File Explorer and find your JDK folder. It’s usually in C:\Program Files\Java, C:\Program Files\Eclipse Adoptium, or C:\Program Files\Microsoft. Copy the folder’s path, such as C:\Program Files\Java\jdk-25.
  2. Click Start, type environment variables, and choose Edit the system environment variables.
  3. Click Environment Variables.
  4. Under System variables, click New. Enter JAVA_HOME as the name and paste your JDK path as the value. Click OK.
  5. Select Path under System variables and click Edit. Click New, type %JAVA_HOME%\bin, and click Move Up until it’s above any older Java entries.
  6. Click OK on every window, then open a new terminal and run java -version again.
Windows 11 New System Variable dialog with JAVA_HOME as the variable name and the JDK folder as the value
(1) Name the variable JAVA_HOME, (2) paste your JDK folder path, and (3) click OK. (Illustration)

Use the JDK folder itself, not its bin subfolder, for JAVA_HOME.

Fix common Java problems

  • “‘java’ is not recognized as an internal or external command.” Java isn’t in your PATH. Add %JAVA_HOME%\bin as described above, then open a new terminal window.
  • The wrong version shows up. An older Java is earlier in your PATH. Move your new entry up, or uninstall old versions in Settings > Apps > Installed apps. Also check for a …\Common Files\Oracle\Java\javapath entry, which can point to a different version.
  • An app says it needs a specific version. You can have several versions installed at once. Point that app to the version it needs in its own settings, or change JAVA_HOME. See how to switch to an older Java version.
  • A .jar file won’t open. See how to run a JAR file on Windows.

Frequently asked questions

Is Java free on Windows 11?

Yes. OpenJDK builds like Eclipse Temurin and the Microsoft Build of OpenJDK are free for everyone, including businesses. Oracle JDK is also free under its current terms, with some conditions for older versions and commercial use.

What’s the difference between the JDK and the JRE?

The JRE only runs Java programs. The JDK runs them and also includes tools for building them. Most modern Java versions are only offered as a JDK.

Do I need Java to use websites?

No. Modern browsers no longer support Java applets, so websites don’t need Java installed on your PC.

How do I uninstall Java?

Go to Settings > Apps > Installed apps, find the Java or JDK entry, click the three-dot menu, and choose Uninstall.