Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This guide covers what's different about setting up Java on Windows compared to Mac or Linux, and gets you to a working JDK installation with your environment configured correctly.
Choose a JDK
Several JDK distributions are available for Windows. Microsoft publishes its own build based on OpenJDK:
- Microsoft Build of OpenJDK — free, open source, supported by Microsoft, available for Windows x64 and ARM64
- Eclipse Temurin (Adoptium) — widely used open-source distribution
- Oracle JDK — requires a license for commercial use
For most developers, Microsoft Build of OpenJDK or Temurin are good choices.
Install with winget
Open a PowerShell or Command Prompt terminal and run:
winget install Microsoft.OpenJDK.21
To install Temurin instead:
winget install EclipseAdoptium.Temurin.21.JDK
Verify the installation:
java -version
Set JAVA_HOME
Unlike on macOS (where /usr/libexec/java_home handles this), on Windows you need to set JAVA_HOME manually. Many tools — Maven, Gradle, Android Studio — require it.
- Open Start, search for Environment Variables, and select Edit the system environment variables.
- Click Environment Variables.
- Under System variables, click New and set:
- Variable name:
JAVA_HOME - Variable value: the path to your JDK, for example
C:\Program Files\Microsoft\jdk-21.0.x.x-hotspot
- Variable name:
- Find the Path variable under System variables, click Edit, and add
%JAVA_HOME%\bin. - Click OK to close all dialogs, then open a new terminal and verify:
echo $env:JAVA_HOME
java -version
javac -version
Tip
If you have multiple JDKs installed, the one listed first in Path takes precedence. Tools like SDKMAN (via WSL) or jEnv can help manage multiple versions.
WSL or native Windows?
For most Java development — web backends, Android, enterprise apps — native Windows works well. Use WSL if your build tooling or deployment target is Linux-specific, or if you're working in a team where everyone else is on Linux/Mac and you want environment parity.
Recommended editors
- Visual Studio Code with the Extension Pack for Java — lightweight, works well for most projects
- IntelliJ IDEA — full-featured IDE, the Community edition is free
Next steps
Windows developer