00:00

Java Environment Setup on Windows – Install the JDK Step by Step

Last updated:

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:

DistributionProvided byNotes
Eclipse TemurinAdoptium (Eclipse Foundation)Popular, free, community-backed. A good default.
Oracle JDKOracleFree under Oracle's licence terms for current releases.
Amazon CorrettoAmazonFree, long-term support.
Microsoft Build of OpenJDKMicrosoftFree, also available through winget.
Azul ZuluAzulFree 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

  1. Open the download page of your chosen distribution, for example adoptium.net for Temurin.
  2. Select Windows, your architecture (x64 for most PCs), package type JDK and the version.
  3. Download the .msi installer and save it to your computer.
Downloaded JDK installer file

3. Install the JDK

  1. Double-click the downloaded installer. The setup wizard opens.
  2. Click Next on the welcome screen.
  3. Keep the default folder, usually C:\Program Files\Java\jdk-25 or C:\Program Files\Eclipse Adoptium\jdk-25…, or choose another one. Remember this path.
  4. 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.
  5. Click Install, wait, and then click Close.
Java installation wizard Choosing the JDK installation folder Java installation completed successfully

4. Set the JAVA_HOME Variable

JAVA_HOME tells tools such as Maven, Gradle and IDEs where the JDK lives.

  1. 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 contains bin).
  2. Press Windows, type environment variables, and open Edit the system environment variables.
  3. Click Environment Variables….
  4. Under System variables, click New….
  5. Variable name: JAVA_HOME. Variable value: the JDK path you copied. Click OK.
JDK installation folder in File Explorer System Properties window with Environment Variables button Environment Variables window

5. Add Java to the PATH

The PATH variable lets you run java and javac from any folder in the command prompt.

  1. In the same System variables list, select Path and click Edit….
  2. Click New and enter %JAVA_HOME%\bin.
  3. Use Move Up to place it above any other Java entries (for example, an old javapath entry), so this JDK is found first.
  4. Click OK in all open windows.
Adding the Java bin folder to the Path variable
Important: environment variable changes apply only to new windows. Close any open Command Prompt or terminal and open a new one before testing.

6. Verify the Installation

Open a new Command Prompt (Windows + R, type cmd, press Enter) and run:

Command Prompt
java -version
javac -version
echo %JAVA_HOME%

You should see output similar to this (vendor and version numbers will differ):

Example output
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
Running javac in the Command Prompt

7. Compile and Run Your First Program

  1. Create a folder such as C:\java-practice.
  2. Create a file named SetupCheck.java with this code (the file name must match the class name):
SetupCheck.java
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());
    }
}
Command Prompt
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
Output
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:

PowerShell or Command Prompt
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

SystemCommand
macOS (Homebrew)brew install --cask temurin@25
Ubuntu / Debiansudo apt install openjdk-25-jdk (Ubuntu 22.04 and later)
Fedora / RHELsudo 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

ProblemCause 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 versionAnother 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 folderIt must point to the JDK root folder (the one containing bin), not to bin itself.
Error: Could not find or load main classRun 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.javaRename the file to match the public class name exactly, including capital letters.
UnsupportedClassVersionErrorThe 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:

ChangeJava versionWhat it means for setup
Single-file source launcherJava 11Run java SetupCheck.java without calling javac first.
Multi-file source launcherJava 22The source launcher also compiles other source files in the program.
Windows 32-bit (x86) port removedJava 24Only 64-bit installers (x64 and aarch64) are available for Windows.
Compact source files and instance main methodsJava 25A 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_HOME to the JDK folder and add %JAVA_HOME%\bin to PATH.
  • Open a new terminal and check java -version and javac -version.
  • Compile with javac, run with java, or use java File.java for single files.

Related Tutorials

14. Official Java Documentation References