How to Install OpenJDK 25 on Ubuntu 26.04, 24.04 and 22.04

Install OpenJDK 25 on Ubuntu 26.04, 24.04 and 22.04 via APT or Eclipse Temurin. Set JAVA_HOME, manage versions, troubleshoot.

Last updatedAuthorJoshua JamesRead time7 minGuide typeUbuntu

OpenJDK 25 gives Ubuntu users the newest Java LTS line for projects that need finalized scoped values, module import declarations, compact source files, and the current Java compiler/runtime stack. If you need to install OpenJDK 25 on Ubuntu 26.04, 24.04, or 22.04, the Ubuntu package is the simplest path because it does not add an external repository.

Eclipse Temurin 25 is also available through the Adoptium APT repository for Ubuntu 24.04 and 22.04. Temurin is useful when an organization standardizes on Adoptium builds, but Adoptium currently has not published Ubuntu 26.04 repository metadata, so Ubuntu 26.04 users should use the Ubuntu package until that support appears.

JDK 25 reached general availability in September 2025 and is described on the OpenJDK 25 project page. Ubuntu and vendor package revisions will continue to change through normal security and update channels, so use the package-manager checks below before installing on production systems.

Install OpenJDK 25 on Ubuntu

Start with the Ubuntu repository package unless you specifically need Temurin. Refresh the APT package index first so Ubuntu can see the current OpenJDK 25 candidate for your release:

sudo apt update
sudo apt upgrade

If your account does not use sudo yet, configure administrative access first with the Ubuntu sudoers guide.

Check OpenJDK 25 Package Availability

Ubuntu currently publishes openjdk-25-jdk for Ubuntu 26.04, 24.04, and 22.04, but the component differs by release. Ubuntu 26.04 uses the main component, while Ubuntu 24.04 and 22.04 use universe updates and security pockets.

Ubuntu ReleasePackage ComponentJava LineInstall Note
Ubuntu 26.04main25.0.xAvailable after a normal APT refresh; current package output can include Ubuntu’s -ea suffix.
Ubuntu 24.04universe-updates and universe-security25.0.xEnable the universe component if APT cannot locate the package.
Ubuntu 22.04universe-updates and universe-security25.0.xEnable the universe component if APT cannot locate the package.

Check your current candidate before installing. This step also confirms whether your mirror has refreshed its package metadata:

apt-cache policy openjdk-25-jdk

On Ubuntu 26.04, the relevant output currently resembles the following. Your mirror hostname can differ:

openjdk-25-jdk:
  Installed: (none)
  Candidate: 25.0.3~7ea-2
  Version table:
     25.0.3~7ea-2 500
        500 http://au.archive.ubuntu.com/ubuntu resolute/main amd64 Packages

On Ubuntu 24.04 and 22.04, the same command should show a candidate from the universe component. If it shows Candidate: (none), enable universe with the Ubuntu universe and multiverse guide, then run sudo apt update again.

Install the OpenJDK 25 JDK

Install the full JDK when you need both the Java runtime and development tools such as javac, jar, and jlink:

sudo apt install openjdk-25-jdk

For runtime-only systems, install one alternative instead of the full JDK. Use the regular JRE for desktop applications or the headless JRE for servers that do not need GUI libraries:

sudo apt install openjdk-25-jre
sudo apt install openjdk-25-jre-headless

Verify OpenJDK 25

Confirm the active Java runtime:

java --version

Ubuntu 26.04 currently reports output similar to this:

openjdk 25.0.3-ea 2026-04-21
OpenJDK Runtime Environment (build 25.0.3-ea+7-Ubuntu-2)
OpenJDK 64-Bit Server VM (build 25.0.3-ea+7-Ubuntu-2, mixed mode, sharing)

Ubuntu 24.04 and 22.04 currently report 25.0.2 final builds from their universe update channels. Package revisions change over time, so the important checks are the major version 25 and the package source shown by APT.

Verify the compiler when you installed the JDK package:

javac --version
javac 25.0.3-ea

Install Eclipse Temurin 25 on Ubuntu 24.04 or 22.04

The Adoptium APT repository currently publishes noble and jammy metadata for Temurin 25. It does not publish a resolute suite yet, so do not point Ubuntu 26.04 at the Ubuntu 24.04 repository as a workaround.

Use this method on Ubuntu 24.04 or 22.04 when you need an Adoptium-managed OpenJDK build. The commands below follow Adoptium’s Linux installation documentation and keep the signing key under /usr/share/keyrings/.

Install Repository Prerequisites

Install the small tools needed to download the signing key and refresh repository metadata:

sudo apt install curl gpg

Import the Adoptium Signing Key

Download the Adoptium signing key and store it as a binary keyring that APT can use for this repository only:

curl -fsSL https://packages.adoptium.net/artifactory/api/gpg/key/public | sudo gpg --dearmor --yes -o /usr/share/keyrings/adoptium.gpg

Add the Adoptium DEB822 Source

Create a DEB822 source file that uses your Ubuntu codename. This must be noble on Ubuntu 24.04 or jammy on Ubuntu 22.04:

. /etc/os-release

printf '%s\n' \
"Types: deb" \
"URIs: https://packages.adoptium.net/artifactory/deb" \
"Suites: ${VERSION_CODENAME}" \
"Components: main" \
"Signed-By: /usr/share/keyrings/adoptium.gpg" | sudo tee /etc/apt/sources.list.d/adoptium.sources > /dev/null

Refresh APT metadata after adding the repository:

sudo apt update

Check that APT can see the Temurin 25 package before installing it:

apt-cache policy temurin-25-jdk

On Ubuntu 24.04, the relevant output currently resembles the following. Ubuntu 22.04 shows jammy instead of noble:

temurin-25-jdk:
  Installed: (none)
  Candidate: 25.0.3.0.0+9-0
  Version table:
     25.0.3.0.0+9-0 500
        500 https://packages.adoptium.net/artifactory/deb noble/main amd64 Packages

Install and Verify Temurin 25

Install the Temurin JDK package:

sudo apt install temurin-25-jdk

Verify the Temurin binaries directly. This avoids confusion if another Java version remains active in update-alternatives:

/usr/lib/jvm/temurin-25-jdk-$(dpkg --print-architecture)/bin/java --version
/usr/lib/jvm/temurin-25-jdk-$(dpkg --print-architecture)/bin/javac --version
openjdk 25.0.3 2026-04-21 LTS
OpenJDK Runtime Environment Temurin-25.0.3+9 (build 25.0.3+9-LTS)
OpenJDK 64-Bit Server VM Temurin-25.0.3+9 (build 25.0.3+9-LTS, mixed mode, sharing)
javac 25.0.3

Use sudo apt install temurin-25-jre instead when you only need a runtime. If another Java version remains the default, use update-alternatives in the next section to switch the active runtime and compiler.

Update Temurin 25

Temurin packages update through the same APT workflow as other repository packages. Use a single-package upgrade when you only want to refresh Temurin 25:

sudo apt update
sudo apt install --only-upgrade temurin-25-jdk

Manage Multiple Java Versions

Ubuntu can keep several Java releases installed at the same time. Use update-alternatives to choose which runtime starts when you run java:

sudo update-alternatives --config java
Selection    Path
* 0          /usr/lib/jvm/java-25-openjdk-amd64/bin/java
  1          /usr/lib/jvm/java-21-openjdk-amd64/bin/java
  2          /usr/lib/jvm/temurin-25-jdk-amd64/bin/java

Run the matching compiler selector when you compile Java code locally:

sudo update-alternatives --config javac

Configure JAVA_HOME

Many build tools expect JAVA_HOME to point at the active JDK directory. Detect the active Java path first instead of hardcoding an architecture-specific directory:

JAVA_HOME_PATH=$(dirname "$(dirname "$(readlink -f "$(command -v java)")")")
printf 'Detected JAVA_HOME: %s\n' "$JAVA_HOME_PATH"
Detected JAVA_HOME: /usr/lib/jvm/java-25-openjdk-amd64

Replace any existing user-level JAVA_HOME export, then add the detected value to your Bash profile:

touch ~/.bashrc
cp ~/.bashrc ~/.bashrc.java-home.bak
sed -i '/^export JAVA_HOME=/d' ~/.bashrc
printf '%s\n' "export JAVA_HOME=$JAVA_HOME_PATH" | tee -a ~/.bashrc > /dev/null
source ~/.bashrc

If you already manage custom Java selection logic in ~/.bashrc, review the backup at ~/.bashrc.java-home.bak before deleting it.

Verify the environment variable in the current shell:

echo "$JAVA_HOME"

For system-wide shell setup, service accounts, or mixed Bash and Zsh environments, use the dedicated Java environment path guide for Ubuntu.

Test OpenJDK 25 with a Sample Program

A short Java 25 source file confirms that the compiler and runtime can use current language features. Create a file named Hello.java:

nano Hello.java

Add the following Java source:

import module java.base;

void main() {
    System.out.println("Hello from OpenJDK 25!");
    System.out.println("Running Java " + System.getProperty("java.version") + " on " + System.getProperty("os.name"));
    System.out.println("Using compact source file syntax without a class declaration.");
}

Compile and run the program:

javac Hello.java
java Hello
Hello from OpenJDK 25!
Running Java 25.0.3-ea on Linux
Using compact source file syntax without a class declaration.

The version line can differ by Ubuntu release or Temurin package revision, but the program should compile and run without preview flags on Java 25.

Compare OpenJDK LTS Releases for Ubuntu

OpenJDK 25 is a good default for new projects, but older LTS releases still matter when a framework, application server, or vendor certification depends on them. Use this comparison as a starting point, then confirm your application’s Java support matrix before upgrading production workloads.

Java LTS LineCommon FitMain Trade-Off
OpenJDK 8Older enterprise applications, legacy build chains, or vendor-certified Java 8 stacksMissing modules, records, virtual threads, and most modern language improvements
OpenJDK 11Applications standardized on Java 11 as a minimum runtimeOlder feature baseline; many new libraries now target Java 17 or newer
OpenJDK 17Conservative production workloads, Spring Boot 3.x, and Jakarta EE 10 stacksNo virtual threads or finalized scoped values
OpenJDK 21Modern server applications that need virtual threads while staying on the previous LTS lineSome Java 25 language and library features are unavailable or still different
OpenJDK 25New projects, Java 25 feature adoption, and teams ready to validate the newest LTS lineFramework and tooling compatibility should be checked before migration

Support windows depend on the vendor or package source, not only the Java version number. When a vendor publishes its own JDK support policy, follow that policy for production maintenance planning.

Troubleshoot OpenJDK 25 on Ubuntu

Fix Unable to Locate Package openjdk-25-jdk

If APT returns the following error, the package index is stale, the universe component is disabled on Ubuntu 24.04 or 22.04, or the host is using an outdated mirror:

E: Unable to locate package openjdk-25-jdk

Refresh APT and enable universe where needed:

sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository universe
sudo apt update
apt-cache policy openjdk-25-jdk

Ubuntu 26.04 does not need universe for this package, but a stale mirror can still cause a temporary lookup failure. Recheck with apt-cache policy openjdk-25-jdk before changing repository files.

Fix Unable to Locate Package temurin-25-jdk

The Temurin package appears only when the Adoptium repository is configured for a supported Ubuntu codename. Check the codename and APT candidate:

. /etc/os-release
echo "$VERSION_CODENAME"
apt-cache policy temurin-25-jdk

If the codename is resolute, Adoptium does not currently publish a matching repository. Remove the accidental source and use the Ubuntu OpenJDK package instead:

sudo rm -f /etc/apt/sources.list.d/adoptium.sources /usr/share/keyrings/adoptium.gpg
sudo apt update
sudo apt install openjdk-25-jdk

If the codename is noble or jammy, recheck the key and source file commands from the Temurin section, then run sudo apt update again.

Fix the Wrong Java Version Being Active

When java --version still shows an older release, select the runtime and compiler explicitly:

sudo update-alternatives --config java
sudo update-alternatives --config javac
java --version
javac --version

Fix JAVA_HOME Not Being Recognized

If a build tool cannot find JAVA_HOME, compare the shell variable with the active Java binary:

echo "$JAVA_HOME"
readlink -f "$(command -v java)"

Update the export line if JAVA_HOME points to an older or removed JDK. Open a new terminal after editing shell startup files, or run source ~/.bashrc for the current Bash session.

Fix Class File Version 69.0 Errors

Java 25 uses class file major version 69. If a build tool reports an unsupported class file version, the application is compiling or running with an older Java release:

Unsupported class file major version 69

Check both the runtime and compiler, then align your build tool configuration with Java 25:

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

Remove OpenJDK 25 from Ubuntu

Remove Ubuntu OpenJDK Packages

Remove the Ubuntu OpenJDK 25 packages that match the install path you used:

sudo apt remove openjdk-25-jdk openjdk-25-jdk-headless openjdk-25-jre openjdk-25-jre-headless

Review optional dependency cleanup before executing it. A reused development machine can have packages that other tools still need:

sudo apt autoremove --dry-run

If the dry run only lists packages you no longer need, run the cleanup without --dry-run:

sudo apt autoremove

Remove Eclipse Temurin Packages and Repository

Remove Temurin 25 if you installed it from Adoptium:

sudo apt remove temurin-25-jdk temurin-25-jre

If no other Temurin packages depend on the Adoptium repository, remove the repository file, signing key, and Adoptium certificate package:

sudo apt remove adoptium-ca-certificates
sudo rm -f /etc/apt/sources.list.d/adoptium.sources /usr/share/keyrings/adoptium.gpg
sudo apt update

Verify Java 25 Removal

Check whether any OpenJDK 25 or Temurin 25 packages remain installed:

dpkg -l 'openjdk-25*' 'temurin-25*' 2>/dev/null | grep '^ii' || echo "Java 25 packages are not installed"
Java 25 packages are not installed

If you exported JAVA_HOME for Java 25, remove or update that line in your shell startup file after uninstalling the package.

Conclusion

OpenJDK 25 is available on Ubuntu 26.04, 24.04, and 22.04 through the Ubuntu package path, while Temurin 25 is a practical Adoptium option on Ubuntu 24.04 and 22.04. After the runtime is active, configure JAVA_HOME, verify javac, and add Apache Maven on Ubuntu when your Java projects need dependency and build management.

Share this guide

Help another Linux user troubleshoot faster

Share this guide with someone troubleshooting Linux systems or saving it for later.

Follow LinuxCapable

Want more LinuxCapable guides in Google?

Add LinuxCapable as a preferred source so Google can show our tutorials more often in Top Stories and mark them as preferred in AI Mode and AI Overviews when relevant.

Add LinuxCapable as a preferred source on Google
Search LinuxCapable

Need another guide?

Search LinuxCapable for package installs, commands, troubleshooting, and follow-up guides related to what you just read.

Found this guide useful?

Support LinuxCapable to keep tutorials free and up to date.

Buy me a coffeeBuy me a coffee
Before commenting, please review our Comments Policy.
Formatting tips for your comment

You can use basic HTML to format your comment. Useful tags currently allowed in published comments:

You type Result
<code>command</code> command
<strong>bold</strong> bold
<em>italic</em> italic
<a href="https://example.com">link</a> link
<blockquote>quote</blockquote> quote block

Add to the discussion

Questions, fixes, command output, and version notes help keep this guide current.

Verify before posting: