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
javaandjavacfrom 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
javaandjavac; - 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 componentsThe two commands we will use most often at the beginning are:
java
javacjava 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 computersARM64 / AArch64
└── Common on Apple Silicon and some newer ARM computers
```
Windows
Open PowerShell and run:
$env:PROCESSOR_ARCHITECTURETypical result:
AMD64Choose the Windows x64 installer for AMD64.
Linux
Run:
uname -mCommon results:
x86_64 → choose x64
aarch64 → choose ARM64macOS
Run:
uname -mCommon results:
x86_64 → Intel Mac
arm64 → Apple SiliconChoosing 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.JDKWinGet will find and install the JDK package.
When installation finishes, close the terminal and open a new one.
Then verify:
java --version
javac --versionExpected 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 : MSIRun the downloaded .msi file.
During Custom Setup, keep the option that adds Java to PATH.
Also enable:
Set or update JAVA_HOMEThe 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 --versionCheck Java's Location
Run:
Get-Command java
Get-Command javacYou can also use:
where.exe java
where.exe javacBoth commands should point to the intended JDK installation.
Check JAVA_HOME
Run:
$env:JAVA_HOMEThen 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
True7. 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 gpgStep 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/nullStep 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.listFor 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-jdkStep 5: Verify the Installation
java --version
javac --versionExpected output should begin with:
openjdk 25...
javac 25...Check the Executable Paths
which java
which javacTo 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-amd64Temurin's official Linux package names use this pattern:
temurin-<version>-jdkOfficial 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@25After installation, verify:
java --version
javac --versionExpected output should begin with version 25.
To list the JDKs detected by macOS:
/usr/libexec/java_home -VOption 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 : PKGOpen 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 --versionOfficial references:
9. Understanding PATH and JAVA_HOME
Two environment settings often appear in Java installation tutorials:
PATH
JAVA_HOMEThey 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
jshellThe 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
└── libTools 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...\bin10. 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%\binClose and reopen PowerShell.
Verify:
$env:JAVA_HOME
java --version
javac --versionLinux 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 ~/.bashrcmacOS 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 ~/.zshrcVerify:
echo "$JAVA_HOME"
java --version
javac --version11. Verify the Complete Installation
Do not stop after checking only java.
A working development environment needs both:
java --version
javac --versionGood Result
java version: 25
javac version: 25The detailed output varies by vendor and update.
Problematic Result
java version: 25
javac version: command not foundThis usually means:
- only a runtime was installed;
PATHpoints to the wrong installation;- the JDK's
binfolder is missing fromPATH.
Check JShell
You can also verify:
jshell --versionThen open it:
jshellInside JShell, try:
System.out.println("Java is ready!");Exit with:
/exit12. Compile and Run a Test Program
Create a folder for the test.
java-install-test/
└── InstallationCheck.javaCreate 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.javaAfter compilation:
java-install-test/
├── InstallationCheck.java
└── InstallationCheck.classRun the compiled class:
java InstallationCheckExpected 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 commandLinux or macOS may display:
java: command not foundPossible solutions:
- Close and reopen the terminal.
- Verify that the JDK is installed.
- Check
PATH. - Make sure
<JDK>/binis included. - 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:
JDKnot only:
JREProblem: The Wrong Java Version Appears
Example:
java 25
javac 21The commands are coming from different installations.
Check their locations.
Windows:
where.exe java
where.exe javacLinux or macOS:
which java
which javacThen 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 25Active:
└── 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 -mor on Windows:
$env:PROCESSOR_ARCHITECTUREThen download the matching x64 or ARM64 package.
Problem: JAVA_HOME Includes bin
Incorrect:
JAVA_HOME=/path/to/jdk/binCorrect:
JAVA_HOME=/path/to/jdkPATH should include:
$JAVA_HOME/bin14. 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.JDKUbuntu or Debian
sudo apt update
sudo apt upgrademacOS
brew update
brew upgrade --cask temurin@25After an update, verify again:
java --version
javac --version15. 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 successfullyWhen every item is complete, your Java development environment is ready.
16. Knowledge Check
- Why should a Java developer install a JDK instead of only a JRE?
- Why does this tutorial recommend JDK 25?
- What is the purpose of
javac? - What is the purpose of
java? - What does
PATHdo? - Where should
JAVA_HOMEpoint? - Why should you check both
java --versionandjavac --version? - What should you check before choosing an x64 or ARM64 installer?
Suggested Answers
- A JDK includes tools for compiling and developing Java applications.
- JDK 25 is the latest LTS release as of July 2026.
javaccompiles Java source code into bytecode.javalaunches the JVM and runs a Java application.PATHtells the terminal where executable commands can be found.- It should point to the JDK root directory, not the
bindirectory. - They may come from different installations or only a runtime may be installed.
- 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.
PATHmakes commands such asjavaandjavacavailable.JAVA_HOMEshould point to the JDK root directory.- Always verify both
javaandjavac. - 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
- OpenJDK JDK 25
- Oracle Java SE Support Roadmap
- Eclipse Temurin Releases
- Install Eclipse Temurin
- Temurin Windows Installation
- Temurin Linux Installation
- Temurin macOS Installation
- Homebrew Temurin 25
This article is part of the Java tutorial series on Pilkupil Lab.