|
| 1 | +--- |
| 2 | +title: Get started with Java on Windows |
| 3 | +description: A guide to help you set up a Java development environment on Windows, including JDK installation, JAVA_HOME configuration, and recommended tools. |
| 4 | +ms.topic: get-started |
| 5 | +ms.subservice: windows-nodejs |
| 6 | +ms.date: 03/27/2026 |
| 7 | +--- |
| 8 | + |
| 9 | +# Get started with Java on Windows |
| 10 | + |
| 11 | +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. |
| 12 | + |
| 13 | +## Choose a JDK |
| 14 | + |
| 15 | +Several JDK distributions are available for Windows. Microsoft publishes its own build based on OpenJDK: |
| 16 | + |
| 17 | +- **[Microsoft Build of OpenJDK](https://www.microsoft.com/openjdk)** — free, open source, supported by Microsoft, available for Windows x64 and ARM64 |
| 18 | +- **[Eclipse Temurin (Adoptium)](https://adoptium.net/)** — widely used open-source distribution |
| 19 | +- **[Oracle JDK](https://www.oracle.com/java/technologies/downloads/)** — requires a license for commercial use |
| 20 | + |
| 21 | +For most developers, Microsoft Build of OpenJDK or Temurin are good choices. |
| 22 | + |
| 23 | +## Install with winget |
| 24 | + |
| 25 | +Open a PowerShell or Command Prompt terminal and run: |
| 26 | + |
| 27 | +```powershell |
| 28 | +winget install Microsoft.OpenJDK.21 |
| 29 | +``` |
| 30 | + |
| 31 | +To install Temurin instead: |
| 32 | + |
| 33 | +```powershell |
| 34 | +winget install EclipseAdoptium.Temurin.21.JDK |
| 35 | +``` |
| 36 | + |
| 37 | +Verify the installation: |
| 38 | + |
| 39 | +```powershell |
| 40 | +java -version |
| 41 | +``` |
| 42 | + |
| 43 | +## Set JAVA_HOME |
| 44 | + |
| 45 | +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. |
| 46 | + |
| 47 | +1. Open **Start**, search for **Environment Variables**, and select **Edit the system environment variables**. |
| 48 | +2. Click **Environment Variables**. |
| 49 | +3. Under **System variables**, click **New** and set: |
| 50 | + - Variable name: `JAVA_HOME` |
| 51 | + - Variable value: the path to your JDK, for example `C:\Program Files\Microsoft\jdk-21.0.x.x-hotspot` |
| 52 | +4. Find the **Path** variable under System variables, click **Edit**, and add `%JAVA_HOME%\bin`. |
| 53 | +5. Click OK to close all dialogs, then open a new terminal and verify: |
| 54 | + |
| 55 | +```powershell |
| 56 | +echo $env:JAVA_HOME |
| 57 | +java -version |
| 58 | +javac -version |
| 59 | +``` |
| 60 | + |
| 61 | +> [!TIP] |
| 62 | +> If you have multiple JDKs installed, the one listed first in `Path` takes precedence. Tools like [SDKMAN](https://sdkman.io/) (via WSL) or [jEnv](https://www.jenv.be/) can help manage multiple versions. |
| 63 | +
|
| 64 | +## WSL or native Windows? |
| 65 | + |
| 66 | +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. |
| 67 | + |
| 68 | +## Recommended editors |
| 69 | + |
| 70 | +- **[Visual Studio Code](https://code.visualstudio.com/)** with the [Extension Pack for Java](https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-pack) — lightweight, works well for most projects |
| 71 | +- **[IntelliJ IDEA](https://www.jetbrains.com/idea/)** — full-featured IDE, the Community edition is free |
| 72 | + |
| 73 | +## Next steps |
| 74 | + |
| 75 | +> [!div class="nextstepaction"] |
| 76 | +> [Learn Java (java.com)](https://dev.java/learn/) |
| 77 | +
|
| 78 | +- [Maven in 5 minutes](https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html) |
| 79 | +- [Gradle quickstart](https://docs.gradle.org/current/userguide/getting_started_eng.html) |
| 80 | +- [Java in Visual Studio Code](https://code.visualstudio.com/docs/languages/java) |
0 commit comments