How to Install Java on Windows 11

To install Java on Windows 11, download a JDK installer such as Microsoft Build of OpenJDK 21 or 25 (both long-term support releases), run it, and keep the option that adds Java to PATH. Then open a new Command Prompt and run java -version and javac -version. If a program asks for a specific version, install that one instead. Set JAVA_HOME only when your development tools need it.

The steps below use Microsoft Build of OpenJDK for native Windows 11. A separate section covers applications that specifically require Oracle Java 8. Java installed inside Windows Subsystem for Linux does not configure Java for Windows applications.

Choose the Java Version Before Downloading

If your app, course, or project names a Java version, install that major version. If nothing is specified, a current long-term support JDK (21 or 25) is the safe choice.

  • Writing or compiling Java programs: Choose a JDK. It supplies the runtime and development tools, including the javac compiler.
  • Running an existing application: Follow its runtime requirements. Some applications include their own runtime, so check their installation instructions before adding a separate one.
  • An app specifically asks for Java 8: Use its vendor-approved Java 8 distribution. The Java download at java.com serves Java 8; it is a different route from installing a current JDK.

If your course uses Python instead of Java, install Python on Windows 11 with the Python Install Manager.

If your course uses the old Borland C++ compiler instead, you can run Turbo C++ on Windows 11.

Install a JDK With the Windows Installer

1. Check Your PC’s Architecture

Open Settings > System > About and look at System type. An x64-based processor uses the Windows x64 package; an ARM-based processor uses an ARM64/AArch64 package when the application supports it. Both are 64-bit, but they are different download choices. For what each System type value means, read about telling if your computer is 32-bit or 64-bit in Windows 11.

2. Download the Required JDK

Open the official Microsoft Build of OpenJDK downloads. Find the required major version, then select the Windows row, matching architecture, and exe installer. Microsoft provides versions including 25, 21, 17, and 11. Choose the current update within the required version.

Choose the .exe installer. The ZIP package needs manual setup, and the MSI is a legacy option.

On a laptop in S mode, Windows blocks .exe installers from outside the Microsoft Store, so you would need to switch out of S mode first.

3. Run the Installer

  1. Open your Downloads folder, double-click the .exe file, and select Yes at the User Account Control prompt.
  2. Accept the license terms. Keep the default install folder under C:\Program Files\Microsoft\, or note the folder you choose.
  3. On the additional tasks screen, leave the PATH option checked. It’s on by default and lets you run java and javac from any terminal.
  4. Check the JAVA_HOME option if Maven, Gradle, or your IDE needs it. It’s off by default.
Microsoft Build of OpenJDK 21 EXE Additional Tasks excerpt showing Modify PATH variable and Associate .jar checked, with Set or override JAVA_HOME variable available and unchecked
Keep PATH selected, and select JAVA_HOME if your tools need it. The .jar association option is shown too. (Recreated interface)
  1. Leave the .jar file association on so you can double-click .jar files, then select Install and Finish.

Microsoft’s installation documentation lists these installer options: the PATH update and .jar association are on by default, and the JAVA_HOME update is off. Use one install method (EXE, MSI, or ZIP) per JDK version. If that version is already installed another way, follow Microsoft’s migration steps first.

4. Verify Java and the Compiler

Close any existing terminal, search Start for Command Prompt, and open a fresh window. Run these separately:

java -version
javac -version

Both commands should show the version you installed. If java works but javac doesn’t, you installed a runtime (JRE) instead of a JDK, or another Java install comes first in PATH.

Install an Oracle JDK When Your Project Requires It

If your course or project requires Oracle JDK, visit Oracle’s Java downloads, choose the required major version and the Windows installer for your supported architecture, and review its license and system requirements. Do not use the Java 8 runtime from java.com in place of a development kit. When the download finishes, open the EXE, approve the installer on a PC you administer, follow setup and note the JDK installation folder. Oracle’s Windows installation guide describes this installer; the version and folder vary.

Open a new Command Prompt and check java -version and javac -version. Both should match the required major version. If a development tool needs JAVA_HOME, use the full environment-variable steps below with this Oracle JDK’s folder, not its bin subfolder. Keep your other PATH entries. Use where.exe java and where.exe javac to track down an unexpected version, then check which JDK the IDE or project uses. Installing a JDK does not mean every application will use it.

Set JAVA_HOME When a Tool Requires It

JAVA_HOME identifies the JDK’s main folder; PATH tells Windows where to find commands. Setting one does not automatically correct the other. Before changing existing variables, copy their values so you can restore them. Apache Maven, for example, can find Java through either JAVA_HOME or PATH, as covered in installing Maven on Windows 11.

  1. Search Start for Edit the system environment variables, open it, and select Environment Variables. This guide to opening environment variables in Windows 11 explains the user and system lists.
  2. Under System variables, select New, or edit an existing JAVA_HOME. System changes may require administrator permission. Set the name to JAVA_HOME and the value to the JDK folder that contains bin.
  3. If PATH does not already point to this JDK’s bin folder, select Path > Edit > New and add %JAVA_HOME%\bin. Preserve unrelated entries.
  4. Select OK in each dialog. Open a new Command Prompt, run echo %JAVA_HOME%, and repeat both version checks.
Steps to set JAVA_HOME in Windows 11: open Environment Variables, add or edit JAVA_HOME, add %JAVA_HOME%\bin to Path, select OK and verify
Illustration: how to set JAVA_HOME in Windows 11.

Do not append \bin to the JAVA_HOME value itself. Do not copy an example folder name without checking that it exists. Microsoft’s Windows Java setup guide documents this configuration.

If Your Application Requires Oracle Java 8

Use this route only when the application’s instructions call for it. Oracle lists Windows 11 support for its 64-bit Java 8 downloads from update 311 onward. On an ARM PC, confirm the application and runtime’s supported architecture with the vendor.

  1. Follow Oracle’s Java 8 offline installation instructions to reach its manual download page. Select the Windows 64-bit offline download appropriate for the application.
  2. Save the installer, close applications, and open the downloaded file. Administrator access is required.
  3. Review the terms before selecting Install, and review any optional software choices. Complete setup and select Close.
  4. Reopen the application and check whether it finds the Java version it needs. Restart Windows if the installer asks you to.

This installs a runtime for that use case; it does not supply the JDK compiler. Follow the app’s own verification instructions instead of assuming a successful JDK command means that app is configured.

Fix Common Installation Problems

Java Is Not Recognized

First open a new terminal. In Command Prompt, run where.exe java. Microsoft’s where command documentation explains that it searches the current folder and PATH. If it finds nothing, confirm setup completed and the installed JDK’s bin folder is in PATH.

The Wrong Version Appears

Run where.exe java and where.exe javac to see the matching locations. Compare those folders with the JDK you intended to use. An earlier Java entry can take precedence; an IDE may also have its own configured JDK.

Oracle documents a JDK 25/Java 8 PATH conflict in which installing Java 8 afterward changes the version returned by the command. Identify the installation involved before repairing it. Repeatedly downloading newer versions will not establish which executable your app uses.

A Working Java Command Does Not Fix the App

If java -version works but your app still can’t find Java, check the app’s required version and architecture, then select the runtime in the app’s own settings or follow its vendor’s instructions.

Java Install Questions

Do I Need JAVA_HOME Just to Run Java?

Not for the basic java -version check if PATH is already correct. Development tools may require JAVA_HOME, so use their requirements.

Should I Remove Older Java Versions?

Check which applications depend on them first. Remove an installation through its normal Windows uninstall entry only after confirming it is no longer needed. If your changes cause a problem, restore the environment values you copied and reopen the affected application. Uninstalling an IDE such as Eclipse doesn’t remove a JDK you installed separately, as explained in uninstalling Eclipse on Windows 11.

Is Java the Same as JavaScript?

No. Installing Java does not enable JavaScript in a web browser. This guide configures Java applications and development tools on Windows.

Once the required version passes the checks, reopen your application or development tool and make sure it uses that installation.