Java 25 is a long-term-support JDK release, but the correct Ubuntu installation method depends on the release and configured official repositories. Check the table first; do not assume apt install openjdk-25-jdk works everywhere.
Java 25 availability by Ubuntu release
The repository availability below was checked on 11 August 2026.
| Ubuntu release | Java 25 available from configured official repositories? | Required method |
|---|---|---|
| Ubuntu 20.04 LTS | No package listed in Ubuntu Packages | Use a supported vendor package/archive, or choose the Java version provided by the release |
| Ubuntu 22.04 LTS | Yes, in the official Universe/security and updates repositories | Enable Universe, refresh APT, confirm the candidate, then install openjdk-25-jdk
|
| Ubuntu 24.04 LTS | Yes, in the official Universe/security and updates repositories | Enable Universe, refresh APT, confirm the candidate, then install openjdk-25-jdk
|
| Ubuntu 25.10 | Yes, in the official Universe/security and updates repositories | Refresh APT, confirm the candidate, then install openjdk-25-jdk
|
| Ubuntu 26.04 LTS | Yes, in the official repositories | Refresh APT, confirm the candidate, then install openjdk-25-jdk
|
Source: Ubuntu Packages search for openjdk-25-jdk
, checked 11 August 2026. Repository components and architectures vary, so confirm the candidate on the target server.
Check the Ubuntu release, architecture, and existing Java
Record the current state before changing it:
. /etc/os-release
printf 'Ubuntu release: %s\n' "$VERSION_ID"
dpkg --print-architecture
java -version 2>&1 || true
javac -version 2>&1 || true
update-alternatives --display java 2>/dev/null || true
If applications already use Java, identify their required major version, service definitions, JAVA_HOME, and rollback procedure. Installing another JDK is reversible; changing the system default can affect every service that follows /usr/bin/java.
Method 1: install OpenJDK 25 with APT where available
Use this method only when the table lists the release as available and apt-cache policy shows a real candidate from the intended Ubuntu repositories.
For Ubuntu 22.04 or 24.04, enable the official Universe component if it is not already enabled:
sudo apt-get update
sudo apt-get install -y software-properties-common
sudo add-apt-repository -y universe
sudo apt-get update
Confirm the candidate before installation:
apt-cache policy openjdk-25-jdk
If Candidate: (none) appears, stop. Do not add an arbitrary PPA or copy a package command for a different Ubuntu release.
Install and verify the JDK:
sudo apt-get install -y openjdk-25-jdk
java -version
javac -version
readlink -f "$(command -v java)"
apt-cache policy openjdk-25-jdk
The JDK includes the runtime and compiler. A headless server can use openjdk-25-jdk-headless when that package fits the application.
Method 2: install a current vendor build where APT is unavailable
When the configured official Ubuntu repositories do not offer Java 25 for the release or architecture, choose a JDK vendor whose support, update, signature/checksum, and licensing terms meet the workload's requirements. Examples include Eclipse Temurin, Oracle JDK, Amazon Corretto, Azul Zulu, and Microsoft Build of OpenJDK.
Prefer the vendor's supported APT repository or signed package instructions for the exact Ubuntu release. For an archive, download the exact version from the official HTTPS location, select the correct architecture, verify the published checksum or signature, and record the version. Do not use an unverified latest URL in an automated production build.
The generic archive workflow is:
- Download the exact vendor archive and its published checksum/signature.
- Verify integrity and authenticity using the vendor's documented procedure.
- Extract to a new versioned directory such as
/opt/jdks/VENDOR-25.0.x, replacing the label with the selected vendor and exact version. - Point one service at that path or register only the required binaries with
update-alternatives. - Record update ownership and the previous path for rollback.
Do not recursively change permissions on an existing JDK tree. Build a separate versioned directory and switch only after verification.
Select Java 25 without breaking other applications
List registered alternatives:
update-alternatives --list java
update-alternatives --list javac
If the server-wide default should change, select matching runtime and compiler entries:
sudo update-alternatives --config java
sudo update-alternatives --config javac
For an application that needs a different version from the system default, set an explicit JDK path in that application's service definition instead. This avoids changing unrelated workloads.
Set and verify JAVA_HOME
Derive JAVA_HOME from the selected binary instead of guessing an architecture-specific directory:
JAVA_BIN="$(readlink -f "$(command -v java)")"
JAVA_HOME="$(dirname "$(dirname "$JAVA_BIN")")"
printf 'JAVA_HOME=%s\n' "$JAVA_HOME"
"$JAVA_HOME/bin/java" -version
Place the verified path in the specific service's environment configuration. Use /etc/environment only when every relevant user and service should share that default, and test how the service manager loads environment variables.