← Table of Contents

Java / 5 of 6 / 12 views

Installing Java: Set Up JDK 25 on Windows, Linux, and macOS

Before writing Java programs, we need a Java Development Kit. In this tutorial, we will install JDK 25 LTS, verify the installation, configure JAVA_HOME, and run a small test program.

In the previous tutorials, we learned what Java is, explored its history and core features, and compared it with C and C++.

Now it is time to prepare our computer for Java development.

The installation process is not difficult, but beginners often encounter problems such as:

  • installing only a JRE instead of a JDK;
  • downloading the wrong processor architecture;
  • forgetting to configure PATH;
  • having several Java versions installed at the same time;
  • running java and javac from different JDK installations.

This tutorial will help you avoid those problems.

Series Navigation

Previous: Java vs C and C++

Current: Installing the Java Development Kit

Next: How Java Compilation Works

Learning Goals

After completing this tutorial, you should be able to:

  • explain what the JDK contains;
  • choose an appropriate Java version;
  • understand the difference between a JDK version and a JDK distribution;
  • install JDK 25 on Windows, Linux, or macOS;
  • verify java and javac;
  • check and configure JAVA_HOME;
  • compile and run a small Java program;
  • solve common Java installation problems.

1. What Are We Installing?

To create Java applications, we need a Java Development Kit, or JDK.

The JDK contains development tools such as:

JDK
├── java      → runs Java applications
├── javac     → compiles Java source code
├── jar       → creates and inspects JAR files
├── javadoc   → generates API documentation
├── jshell    → interactive Java shell
└── runtime libraries and JVM components

The two commands we will use most often at the beginning are:

java
javac

java launches a Java application.

javac compiles Java source code into bytecode.

JDK vs JRE

A JRE is intended mainly to run Java applications.

A JDK includes the tools needed to develop them.

If you only need to run Java applications, runtime components are enough. If you need to write and compile Java, you need a JDK.

For this tutorial series, always install a JDK.

2. Which Java Version Should You Install?

As of July 2026:

  • JDK 26 is the latest feature release;
  • JDK 25 is the latest Long-Term Support release;
  • JDK 27 is still planned for September 2026.

For this beginner series, we will use JDK 25 LTS.

An LTS release is a practical choice because vendors support it for a longer period.

JDK 25 is suitable for:

  • learning modern Java;
  • personal projects;
  • backend development;
  • long-lived applications;
  • tutorials that should remain relevant for several years.

When Should You Use Another Version?

Use a different Java version when:

  • a company project requires it;
  • a framework supports only certain versions;
  • an Android or build tool specifies a version;
  • you are maintaining an older application;
  • your teacher or course provides a required version.

For a new standalone Java project, JDK 25 LTS is a reasonable default.

Official references:

3. Which JDK Distribution Should You Choose?

Java SE is a specification and platform.

Several vendors provide JDK builds based on OpenJDK.

Examples include:

  • Eclipse Temurin;
  • Oracle JDK;
  • Microsoft Build of OpenJDK;
  • Amazon Corretto;
  • Azul Zulu;
  • Red Hat builds of OpenJDK.

For this tutorial, we will use Eclipse Temurin 25.

Eclipse Temurin is an OpenJDK-based distribution provided by the Eclipse Adoptium project. It is available for Windows, Linux, and macOS.

Using Temurin also gives this tutorial one consistent installation source across all three operating systems.

Does Java Code Change Between Vendors?

Normal Java source code should not depend on the vendor.

For example:

System.out.println("Hello, Java!");

The code is the same whether the JDK comes from Temurin, Oracle, Microsoft, or another compatible distribution.

Differences are more likely to involve:

  • support contracts;
  • update schedules;
  • packaging;
  • supported platforms;
  • bundled tools;
  • licensing;
  • vendor-specific patches.

For learning standard Java, any compatible and actively maintained JDK is generally suitable.

Official reference:

4. Check Your Computer Architecture

Before downloading an installer, identify your computer architecture.

The most common options are:

x64 / x86-64 / AMD64
└── Common on Intel and AMD desktop or laptop computers

ARM64 / AArch64
└── Common on Apple Silicon and some newer ARM computers
```

Windows

Open PowerShell and run:

$env:PROCESSOR_ARCHITECTURE

Typical result:

AMD64

Choose the Windows x64 installer for AMD64.

Linux

Run:

uname -m

Common results:

x86_64   → choose x64
aarch64  → choose ARM64

macOS

Run:

uname -m

Common results:

x86_64   → Intel Mac
arm64    → Apple Silicon

Choosing the wrong architecture can cause the installer to fail or the application to run inefficiently through a compatibility layer.

5. Installation Overview

The installation flow is similar on every operating system:

Choose JDK version → Choose operating system → Choose processor architecture → Install the JDK → Verify java and javac → Check JAVA_HOME → Compile a test program

We will now follow this process on each platform.

6. Install JDK 25 on Windows

Windows users can install Eclipse Temurin using WinGet or the graphical MSI installer.

Option A: Install with WinGet

Open PowerShell or Windows Terminal as a normal user.

Run:

winget install EclipseAdoptium.Temurin.25.JDK

WinGet will find and install the JDK package.

When installation finishes, close the terminal and open a new one.

Then verify:

java --version
javac --version

Expected output should begin with version 25:

openjdk 25...
javac 25...

The exact update and build numbers may be different.

Option B: Install with the MSI Installer

Use the official Temurin download page:

Choose:

Version       : JDK 25 - LTS
Operating Sys.: Windows
Architecture  : x64
Package       : JDK
Installer     : MSI

Run the downloaded .msi file.

During Custom Setup, keep the option that adds Java to PATH.

Also enable:

Set or update JAVA_HOME

The installation normally uses a directory similar to:

C:\Program Files\Eclipse Adoptium\jdk-25...

After installation, open a new PowerShell window and run:

java --version
javac --version

Check Java's Location

Run:

Get-Command java
Get-Command javac

You can also use:

where.exe java
where.exe javac

Both commands should point to the intended JDK installation.

Check JAVA_HOME

Run:

$env:JAVA_HOME

Then check that its bin folder contains Java:

Test-Path "$env:JAVA_HOME\bin\java.exe"
Test-Path "$env:JAVA_HOME\bin\javac.exe"

Expected result:

True
True

7. Install JDK 25 on Ubuntu or Debian

Eclipse Adoptium provides a package repository for Debian-based Linux distributions.

Step 1: Install Repository Requirements

sudo apt update
sudo apt install -y wget apt-transport-https gpg

Step 2: Add the Adoptium Signing Key

wget -qO - \
  https://packages.adoptium.net/artifactory/api/gpg/key/public \
  | gpg --dearmor \
  | sudo tee /etc/apt/trusted.gpg.d/adoptium.gpg \
  > /dev/null

Step 3: Add the Adoptium Repository

echo "deb https://packages.adoptium.net/artifactory/deb \
$(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" \
| sudo tee /etc/apt/sources.list.d/adoptium.list

For Linux Mint, the base Ubuntu codename may need to be used instead of the Mint codename.

Step 4: Install Temurin 25

sudo apt update
sudo apt install temurin-25-jdk

Step 5: Verify the Installation

java --version
javac --version

Expected output should begin with:

openjdk 25...
javac 25...

Check the Executable Paths

which java
which javac

To see the final resolved locations:

readlink -f "$(command -v java)"
readlink -f "$(command -v javac)"

Find JAVA_HOME

Run:

dirname "$(dirname "$(readlink -f "$(command -v javac)")")"

The result will look similar to:

/usr/lib/jvm/temurin-25-jdk-amd64

Temurin's official Linux package names use this pattern:

temurin-<version>-jdk

Official reference:

8. Install JDK 25 on macOS

macOS users can install the JDK with Homebrew or a graphical PKG installer.

Option A: Install with Homebrew

When Homebrew is already installed, run:

brew install --cask temurin@25

After installation, verify:

java --version
javac --version

Expected output should begin with version 25.

To list the JDKs detected by macOS:

/usr/libexec/java_home -V

Option B: Install with the PKG Installer

Open the official Temurin download page:

Choose:

Version       : JDK 25 - LTS
Operating Sys.: macOS
Architecture  : aarch64 for Apple Silicon
                x64 for Intel
Package       : JDK
Installer     : PKG

Open the .pkg file and follow the installation steps.

Temurin is normally installed under:

/Library/Java/JavaVirtualMachines/

A typical location is:

/Library/Java/JavaVirtualMachines/temurin-25.jdk/

Verify the installation:

java --version
javac --version

Official references:

9. Understanding PATH and JAVA_HOME

Two environment settings often appear in Java installation tutorials:

PATH
JAVA_HOME

They have different purposes.

PATH

PATH tells the terminal where to find executable commands.

When the JDK's bin directory is in PATH, these commands work from any folder:

java
javac
jar
jshell

The relationship looks like this:

Terminal receives command javac → searches every folder in PATH → finds <JDK>/bin/javac → runs the compiler

JAVA_HOME

JAVA_HOME points to the JDK's root directory.

Example:

JAVA_HOME
└── /path/to/jdk-25
    ├── bin
    ├── conf
    ├── include
    ├── jmods
    └── lib

Tools such as Gradle, Maven, application servers, or IDEs may use JAVA_HOME to locate the JDK.

JAVA_HOME should point to the JDK folder, not its bin folder.

Correct:

C:\Program Files\Eclipse Adoptium\jdk-25...

Incorrect:

C:\Program Files\Eclipse Adoptium\jdk-25...\bin

10. Configure JAVA_HOME Manually

Installers and package managers often configure Java automatically.

Only configure it manually when it is missing or points to the wrong JDK.

Windows

Open Settings → System → About → Advanced system settings → Environment Variables.

Create or update:

Variable name : JAVA_HOME
Variable value: C:\Program Files\Eclipse Adoptium\jdk-25...

Then edit Path and ensure it contains:

%JAVA_HOME%\bin

Close and reopen PowerShell.

Verify:

$env:JAVA_HOME
java --version
javac --version

Linux with Bash

Find the JDK directory:

dirname "$(dirname "$(readlink -f "$(command -v javac)")")"

Add the result to ~/.bashrc:

export JAVA_HOME="/usr/lib/jvm/temurin-25-jdk-amd64"
export PATH="$JAVA_HOME/bin:$PATH"

Apply the changes:

source ~/.bashrc

macOS with Zsh

macOS commonly uses Zsh.

Add this to ~/.zshrc:

export JAVA_HOME=$(/usr/libexec/java_home -v 25)
export PATH="$JAVA_HOME/bin:$PATH"

Apply the changes:

source ~/.zshrc

Verify:

echo "$JAVA_HOME"
java --version
javac --version

11. Verify the Complete Installation

Do not stop after checking only java.

A working development environment needs both:

java --version
javac --version

Good Result

java  version: 25
javac version: 25

The detailed output varies by vendor and update.

Problematic Result

java  version: 25
javac version: command not found

This usually means:

  • only a runtime was installed;
  • PATH points to the wrong installation;
  • the JDK's bin folder is missing from PATH.

Check JShell

You can also verify:

jshell --version

Then open it:

jshell

Inside JShell, try:

System.out.println("Java is ready!");

Exit with:

/exit

12. Compile and Run a Test Program

Create a folder for the test.

java-install-test/
└── InstallationCheck.java

Create InstallationCheck.java:

public class InstallationCheck {

public static void main(String[] args) {
System.out.println("JDK installation successful!");
System.out.println(
"Java version: "
+ System.getProperty("java.version")
);
}
}
```

Open the terminal in the same folder.

Compile the file:

javac InstallationCheck.java

After compilation:

java-install-test/
├── InstallationCheck.java
└── InstallationCheck.class

Run the compiled class:

java InstallationCheck

Expected output:

JDK installation successful!
Java version: 25...

The update number after 25 may vary.

What Just Happened?

InstallationCheck.java → (compiled by javac) → InstallationCheck.class → (run by java) → JVM executes the program

We will examine this process more deeply in the next tutorial.

13. Common Installation Problems

Problem: java Is Not Recognized

Windows may display:

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

Linux or macOS may display:

java: command not found

Possible solutions:

  1. Close and reopen the terminal.
  2. Verify that the JDK is installed.
  3. Check PATH.
  4. Make sure <JDK>/bin is included.
  5. Restart the computer when an installer changed system environment variables.

Problem: java Works but javac Does Not

This often means a runtime was installed instead of a full JDK.

Check the downloaded package.

It should be labeled:

JDK

not only:

JRE

Problem: The Wrong Java Version Appears

Example:

java 25
javac 21

The commands are coming from different installations.

Check their locations.

Windows:

where.exe java
where.exe javac

Linux or macOS:

which java
which javac

Then correct PATH and JAVA_HOME.

Problem: Several JDKs Are Installed

Having multiple JDKs is not always a problem.

The important question is which one is active.

Installed:
├── JDK 17
├── JDK 21
└── JDK 25

Active:
└── determined by PATH, JAVA_HOME, or tool settings
```

An IDE can also use a different JDK from the terminal.

Always check the IDE's project SDK and Gradle or Maven settings separately.

Problem: Wrong Processor Architecture

Typical symptoms include:

  • installer refusal;
  • application launch failure;
  • architecture-related error messages;
  • unexpected compatibility translation.

Check:

uname -m

or on Windows:

$env:PROCESSOR_ARCHITECTURE

Then download the matching x64 or ARM64 package.

Problem: JAVA_HOME Includes bin

Incorrect:

JAVA_HOME=/path/to/jdk/bin

Correct:

JAVA_HOME=/path/to/jdk

PATH should include:

$JAVA_HOME/bin

14. Updating the JDK

JDK updates can include:

  • security fixes;
  • bug fixes;
  • performance improvements;
  • certificate updates;
  • platform compatibility fixes.

Keep the installed JDK updated.

Windows

With WinGet:

winget upgrade EclipseAdoptium.Temurin.25.JDK

Ubuntu or Debian

sudo apt update
sudo apt upgrade

macOS

brew update
brew upgrade --cask temurin@25

After an update, verify again:

java --version
javac --version

15. Installation Checklist

Use this checklist before continuing.

[ ] JDK 25 is installed
[ ] java --version works
[ ] javac --version works
[ ] Both commands use version 25
[ ] java and javac come from the same JDK
[ ] JAVA_HOME points to the JDK root
[ ] The JDK bin folder is available through PATH
[ ] InstallationCheck.java compiles successfully
[ ] InstallationCheck runs successfully

When every item is complete, your Java development environment is ready.

16. Knowledge Check

  1. Why should a Java developer install a JDK instead of only a JRE?
  2. Why does this tutorial recommend JDK 25?
  3. What is the purpose of javac?
  4. What is the purpose of java?
  5. What does PATH do?
  6. Where should JAVA_HOME point?
  7. Why should you check both java --version and javac --version?
  8. What should you check before choosing an x64 or ARM64 installer?

Suggested Answers

  1. A JDK includes tools for compiling and developing Java applications.
  2. JDK 25 is the latest LTS release as of July 2026.
  3. javac compiles Java source code into bytecode.
  4. java launches the JVM and runs a Java application.
  5. PATH tells the terminal where executable commands can be found.
  6. It should point to the JDK root directory, not the bin directory.
  7. They may come from different installations or only a runtime may be installed.
  8. Check the computer's processor architecture.

Key Takeaways

Choose JDK 25 LTS → Install a compatible distribution → Verify java and javac → Check PATH and JAVA_HOME → Compile and run a test program

The most important points are:

  • Install a JDK when developing Java applications.
  • JDK 25 LTS is the recommended version for this tutorial series.
  • Eclipse Temurin is one OpenJDK-based distribution available across major platforms.
  • Windows users can install it using WinGet or MSI.
  • Ubuntu and Debian users can install it through the Adoptium repository.
  • macOS users can use Homebrew or a PKG installer.
  • PATH makes commands such as java and javac available.
  • JAVA_HOME should point to the JDK root directory.
  • Always verify both java and javac.
  • Compile a small test file before installing an IDE.

What's Next?

Your Java development environment is now ready.

In the next tutorial, we will examine:

How Java Source Code Is Compiled and Executed

We will follow the complete process:

.java source file → Java compiler → .class bytecode → Class loader and JVM → Program output

Official Sources and Further Reading

  1. OpenJDK JDK 25
  2. Oracle Java SE Support Roadmap
  3. Eclipse Temurin Releases
  4. Install Eclipse Temurin
  5. Temurin Windows Installation
  6. Temurin Linux Installation
  7. Temurin macOS Installation
  8. Homebrew Temurin 25

This article is part of the Java tutorial series on Pilkupil Lab.