Java Environment Setup on Windows – Install the JDK Step by Step
Before you can write and run Java programs, you need to install the Java Development Kit (JDK) and tell Windows where to find it. This guide walks you through every step on Windows 10 and Windows 11: downloading the JDK, installing it, setting the JAVA_HOME and PATH environment variables, verifying the installation, and running your first program.
The whole process takes about 10 minutes. The screenshots show an older JDK installer, but the steps are the same for current versions such as JDK 25.
1. Choose a JDK
Java is free and open source (OpenJDK), and several vendors publish ready-to-install builds. Any of these works for learning and for production:
| Distribution | Provided by | Notes |
|---|---|---|
| Eclipse Temurin | Adoptium (Eclipse Foundation) | Popular, free, community-backed. A good default. |
| Oracle JDK | Oracle | Free under Oracle's licence terms for current releases. |
| Amazon Corretto | Amazon | Free, long-term support. |
| Microsoft Build of OpenJDK | Microsoft | Free, also available through winget. |
| Azul Zulu | Azul | Free community builds. |
Pick the latest LTS (Long-Term Support) version, currently JDK 25, and the x64 MSI installer for Windows (or aarch64 on ARM laptops). There is no 32-bit (x86) Windows build of JDK 24 or later.
2. Download the Installer
- Open the download page of your chosen distribution, for example
adoptium.netfor Temurin. - Select Windows, your architecture (x64 for most PCs), package type JDK and the version.
- Download the
.msiinstaller and save it to your computer.
3. Install the JDK
- Double-click the downloaded installer. The setup wizard opens.
- Click Next on the welcome screen.
- Keep the default folder, usually
C:\Program Files\Java\jdk-25orC:\Program Files\Eclipse Adoptium\jdk-25…, or choose another one. Remember this path. - Temurin and some other installers offer to set JAVA_HOME and add to PATH for you. Enable both options; you can then skip the JAVA_HOME and PATH sections below.
- Click Install, wait, and then click Close.
4. Set the JAVA_HOME Variable
JAVA_HOME tells tools such as Maven, Gradle and IDEs where the JDK lives.
- Open File Explorer, go to the JDK folder and copy its path, for example
C:\Program Files\Eclipse Adoptium\jdk-25.0.5.8-hotspot(the folder that containsbin). - Press Windows, type environment variables, and open Edit the system environment variables.
- Click Environment Variables….
- Under System variables, click New….
- Variable name:
JAVA_HOME. Variable value: the JDK path you copied. Click OK.
5. Add Java to the PATH
The PATH variable lets you run java and javac from any folder in the command prompt.
- In the same System variables list, select Path and click Edit….
- Click New and enter
%JAVA_HOME%\bin. - Use Move Up to place it above any other Java entries (for example, an old
javapathentry), so this JDK is found first. - Click OK in all open windows.
6. Verify the Installation
Open a new Command Prompt (Windows + R, type cmd, press Enter) and run:
java -version
javac -version
echo %JAVA_HOME%
You should see output similar to this (vendor and version numbers will differ):
openjdk version "25.0.5" 2026-10-20 LTS OpenJDK Runtime Environment Temurin-25.0.5+8 (build 25.0.5+8-LTS) OpenJDK 64-Bit Server VM Temurin-25.0.5+8 (build 25.0.5+8-LTS, mixed mode, sharing) javac 25.0.5 C:\Program Files\Eclipse Adoptium\jdk-25.0.5.8-hotspot
7. Compile and Run Your First Program
- Create a folder such as
C:\java-practice. - Create a file named
SetupCheck.javawith this code (the file name must match the class name):
public class SetupCheck {
public static void main(String[] args) {
System.out.println("Java is installed and working!");
System.out.println("Running on Java " + Runtime.version().feature());
}
}
cd C:\java-practice
javac SetupCheck.java # creates SetupCheck.class
java SetupCheck # runs the program
java SetupCheck.java # Java 11+: compile and run in one step
Java is installed and working! Running on Java 25
The second line shows the feature version of your JDK, so it may print 25 or another number on your computer.
8. Faster Option: Install with winget
Windows 10 (1809+) and Windows 11 include the winget package manager. One command installs a JDK and sets up the paths:
winget search "JDK"
winget install EclipseAdoptium.Temurin.25.JDK
Open a new terminal afterwards and run java -version to confirm.
9. Installing on macOS and Linux
| System | Command |
|---|---|
| macOS (Homebrew) | brew install --cask temurin@25 |
| Ubuntu / Debian | sudo apt install openjdk-25-jdk (Ubuntu 22.04 and later) |
| Fedora / RHEL | sudo dnf install java-25-openjdk-devel |
| Any OS (SDKMAN!) | sdk list java to find the current Temurin 25 identifier, then for example sdk install java 25.0.5.0+8-tem; SDKMAN! can also switch between versions |
10. Install an IDE (Optional)
You can write Java in any text editor, but an IDE adds auto-completion, error highlighting, debugging and one-click running:
- IntelliJ IDEA Community Edition: the most popular Java IDE, free.
- Eclipse IDE for Java Developers: free and open source.
- Visual Studio Code with the "Extension Pack for Java": lightweight and free.
Most IDEs detect your JDK automatically through JAVA_HOME, and some can download a JDK for you.
11. Troubleshooting Common Problems
| Problem | Cause and fix |
|---|---|
'javac' is not recognized as an internal or external command | %JAVA_HOME%\bin is missing from PATH, or the terminal was opened before you changed it. Fix the path and open a new terminal. |
java -version shows an old version | Another Java entry appears earlier in PATH (often C:\Program Files\Common Files\Oracle\Java\javapath). Move %JAVA_HOME%\bin to the top. |
JAVA_HOME points to the wrong folder | It must point to the JDK root folder (the one containing bin), not to bin itself. |
Error: Could not find or load main class | Run java from the folder containing the .class file, and use the class name without .class. |
class X is public, should be declared in a file named X.java | Rename the file to match the public class name exactly, including capital letters. |
UnsupportedClassVersionError | The class was compiled with a newer JDK than the one running it (Java 25 class files have version 69.0). Run it with the same or a newer Java version, or compile with javac --release for the older version. |
12. Java Version Improvements and Java 25 Updates
The installation steps are the same for every recent JDK, but a few changes matter when you set up Java 25:
| Change | Java version | What it means for setup |
|---|---|---|
| Single-file source launcher | Java 11 | Run java SetupCheck.java without calling javac first. |
| Multi-file source launcher | Java 22 | The source launcher also compiles other source files in the program. |
| Windows 32-bit (x86) port removed | Java 24 | Only 64-bit installers (x64 and aarch64) are available for Windows. |
Compact source files and instance main methods | Java 25 | A first test program can be as short as void main() { IO.println("Hello"); }. |
All of these are standard features. See How to Write a Java Program for a compact source file example.
13. Summary
- Download a JDK (for example Eclipse Temurin, latest LTS) as an x64 MSI installer.
- Install it and note the folder.
- Set
JAVA_HOMEto the JDK folder and add%JAVA_HOME%\bintoPATH. - Open a new terminal and check
java -versionandjavac -version. - Compile with
javac, run withjava, or usejava File.javafor single files.
Related Tutorials
14. Official Java Documentation References
- JDK 25 Installation on Microsoft Windows Platforms (Oracle)
- Overview of JDK Installation (Java SE 25)
- The java Command (Java SE 25)
- The javac Command (Java SE 25)
- JEP 479: Remove the Windows 32-bit x86 Port
- JEP 330: Launch Single-File Source-Code Programs
- JEP 458: Launch Multi-File Source-Code Programs
- Eclipse Adoptium: Installation on Windows