How to Install Java on Windows (Step by Step)

The fastest way to install Java on Windows is to download an Eclipse Temurin MSI or use winget. Both methods set JAVA_HOME and update PATH automatically. You'll be running java -version in under five minutes.

Option 1: Graphical installer (MSI)

  1. Go to adoptium.net, choose Latest LTS (Java 21 as of 2026), select Windows x64, and download the .msi.
  2. Run the installer. On the Custom Setup screen, enable:
    • Add to PATH
    • Set JAVA_HOME variable
  3. Click Install and let it finish.
  4. Open a new Command Prompt (the old one won't see the updated PATH) and run:
java -version

Expected output:

openjdk version "21.0.x" 2024-xx-xx
OpenJDK Runtime Environment Temurin-21...

Option 2: winget (one command)

winget install EclipseAdoptium.Temurin.21.JDK

Or for Microsoft's own build:

winget install Microsoft.OpenJDK.21

Both set JAVA_HOME and PATH. Open a new PowerShell window and verify with java -version.

Option 3: Oracle JDK (if required by policy)

Download the installer from oracle.com/java/technologies/downloads. Note: Oracle JDK requires a paid subscription for commercial production use. Use an OpenJDK build unless your organisation specifically mandates Oracle.

Setting JAVA_HOME manually (if missed)

If you forgot to check Set JAVA_HOME during install:

  1. Find the install path: typically C:\Program Files\Eclipse Adoptium\jdk-21.x.x.x-hotspot\
  2. Open System Properties > Advanced > Environment Variables
  3. Under System variables, click New: variable JAVA_HOME, value the path above.
  4. Edit the Path variable and add %JAVA_HOME%\bin at the top.
  5. Open a new terminal and verify.

Installing multiple Java versions

Run multiple MSI installers side by side — Windows keeps each JDK in its own directory. To switch between them, change the JAVA_HOME environment variable and put %JAVA_HOME%\bin first in PATH. Some IDEs (IntelliJ, Eclipse) let you pick the JDK per project, so system-level switching is often unnecessary during development.

Verify the compiler too

javac -version

If java -version works but javac -version fails, you installed a JRE instead of a JDK. Re-download and choose the JDK build.

Common problems

  • "java is not recognized" — you are in an old terminal window. Open a new one after installation.
  • Wrong version prints — another JDK higher on PATH is winning. Check where java to see which binary is used.
  • 32-bit vs 64-bit — download the x64 installer on a 64-bit machine (almost all Windows PCs since 2010). Running 32-bit Java on 64-bit Windows wastes RAM and limits heap size.