Skip to main content
Guides Menu

How to Install Java on Windows

Install a JDK on Windows so Java apps, build tools, Android Studio, and IDEs can find java, javac, and JAVA_HOME.

Vishal Hulawale
April 2026·5 min read

Supported Versions

21.0.1017.0.1811.0.30

Official Source

Oracle JDK 21 (official)

Environment Setup

1 environment variable + 1 PATH entry

Verify Step

java -version

DevTools Installer is not affiliated with, endorsed by, or sponsored by the publisher of Java (JDK). All product names and logos are trademarks of their respective owners. Downloads are sourced directly from the official publisher.

Install With DevTools Installer

Use this path if you want DevTools Installer to download the official package and handle the Windows setup for you.

  1. 1Open DevTools Installer.
  2. 2In Core Programming Runtimes, select "Java (JDK)" and choose the JDK version you need.
  3. 3Click "Install Selected".
  4. 4Let the installer download the official MSI, run it silently, set JAVA_HOME to the JDK root directory, and add to PATH.
  5. 5Open a new terminal window after the install finishes.
  6. 6Run and to confirm Windows finds both the runtime and the compiler.

Download Source

DevTools Installer downloads from the official publisher:

https://download.oracle.com/java/21/latest/jdk-21_windows-x64_bin.msi

PATH & Environment Variables

DevTools Installer sets the following automatically:

Environment variables

JAVA_HOME=C:\Program Files\Java\jdk-{version}

PATH entries

%JAVA_HOME%\bin

Verification

DevTools Installer verifies the install by running:

java -version

Expected output: java version "21.0.x" or openjdk version "21.0.x"

Manual Installation Steps

Use these steps if you want to run the installer yourself and apply the Windows PATH or environment changes manually.

  1. 1Download the MSI installer from the official source: https://download.oracle.com/java/21/latest/jdk-21_windows-x64_bin.msi
  2. 2Run the installer and keep note of the JDK install folder. A typical path is .
  3. 3If you need a silent install, run:
  4. 4Set JAVA_HOME to the JDK root directory. Do not point it to the \bin folder.
  5. 5Add to your system PATH.
  6. 6Open a new terminal and run , then run .

Need to upgrade, downgrade, or remove Java (JDK)?

DevTools Installer can also upgrade Java (JDK) to a newer version, roll back to an older one, or cleanly uninstall it — including PATH entries and environment variables. No manual cleanup required.

What Is Java (JDK) Used For?

  • Building enterprise backend services with Spring Boot or Jakarta EE.
  • Android app development — Android Studio requires a JDK to compile projects.
  • Running build tools like Maven and Gradle, both of which depend on a JDK.
  • Developing cross-platform desktop apps with JavaFX or Swing.
  • Running big-data frameworks such as Apache Spark, Hadoop, and Kafka that are built on the JVM.

Common Issues And Fixes

Check the problem and the exact fix before you reinstall anything. Some guides also include the reason the issue happens.

Problem

JAVA_HOME is not set or points to the wrong directory

Exact fix

Open System Properties → Environment Variables and set JAVA_HOME to the root of your JDK directory (e.g., C:\Program Files\Java\jdk-21.0.10). Do not include the \bin folder in JAVA_HOME.

Problem

"java" is not recognized as an internal or external command

Exact fix

Ensure %JAVA_HOME%\bin is in your system PATH. Open a new terminal after making changes — existing terminals do not pick up PATH updates.

Problem

Multiple Java versions conflict with each other

Exact fix

Check your PATH for old Java entries (e.g., C:\Program Files\Java\jdk-17). Remove outdated entries or reorder them so the desired version appears first. Run "where java" to see which binary Windows resolves.

Problem

Maven or Gradle reports "invalid target release" errors

Exact fix

The JDK version used by your build tool must match or exceed the target version in your project. Run "java -version" and compare with your pom.xml or build.gradle settings.

Tips for Java (JDK)

  • Use JDK 21 (LTS) for new projects — it receives long-term security updates and is the current recommended version for production.
  • JDK 17 is the previous LTS release and is still widely used in enterprise environments. Choose it if your project or CI pipeline requires it.
  • JDK 11 is end-of-life for Oracle JDK but still supported through Adoptium Temurin. Use it only for legacy projects that cannot upgrade.
  • After installation, always verify both "java -version" and "javac -version" to confirm the compiler is also available.
  • If you switch between JDK versions frequently, consider using a version manager or simply update JAVA_HOME to point to the version you need.

Related Guides

Back to All Guides