Skip to main content
How to Install Java 25 on Ubuntu - Virtarix Blog

How to Install Java 25 on Ubuntu

December 5, 2025 · Blog / Technical Guides

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
Swipe to view the full table

Source: Ubuntu Packages search for VX0, 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:

Inspect Ubuntu architecture and installed Java
. /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:

Enable Ubuntu Universe and refresh package metadata
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:

Inspect the OpenJDK 25 package candidate
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:

Install and verify OpenJDK 25 with APT
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.

Need a reliable Ubuntu VPS for this Java 25 runtime?

After Java installs cleanly, run your customer-managed workload on a Virtarix Ubuntu VPS with root access, NVMe storage, one included backup, and one included snapshot.

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:

  1. Download the exact vendor archive and its published checksum/signature.
  2. Verify integrity and authenticity using the vendor's documented procedure.
  3. Extract to a new versioned directory such as /opt/jdks/VENDOR-25.0.x, replacing the label with the selected vendor and exact version.
  4. Point one service at that path or register only the required binaries with update-alternatives.
  5. 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:

List Java runtime and compiler alternatives
update-alternatives --list java
update-alternatives --list javac

If the server-wide default should change, select matching runtime and compiler entries:

Select matching Java and javac alternatives
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:

Derive JAVA_HOME from the selected Java binary
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.

Verify the installation with a small program

Compile and run a temporary program in a disposable directory:

Compile and run a Java 25 smoke test
test_dir="$(mktemp -d)"
cd "$test_dir"
printf '%s\n' 'public class Test { public static void main(String[] args) { System.out.println(Runtime.version()); } }' > Test.java
javac Test.java
java Test
cd /
rm -r "$test_dir"

Confirm that the reported feature version is 25 and that the application starts with the intended JDK path. Preview features are not required for a normal Java 25 installation; enable one only for the specific build and runtime after compatibility testing.

Update and rollback

APT-managed OpenJDK updates arrive through the configured Ubuntu repositories. Monitor security updates, confirm service restart requirements, and test the workload after an update.

For a vendor archive, track the vendor's security releases and repeat the checksum/signature-verified installation into a new versioned directory. Switch the service or alternative only after the new build passes its smoke and application tests.

To roll back, restore the previous service path or choose the previous matching java and javac alternatives. Do not delete the previous JDK until the application, scheduled jobs, monitoring, and restart path have passed verification.

Troubleshooting

APT cannot locate openjdk-25-jdk

Confirm the Ubuntu release and repository components, run sudo apt-get update, and inspect apt-cache policy openjdk-25-jdk. If no candidate exists for the release or architecture, use Method 2 rather than adding an unverified repository.

The wrong Java version runs

Compare command -v java, readlink -f "$(command -v java)", update-alternatives --display java, the service's environment, and its actual process command. Interactive shells and system services can use different PATH or JAVA_HOME values.

java and javac report different versions

Select matching alternatives or configure the application to use one explicit JDK directory. Rebuild classes compiled for the wrong target where necessary.

The application fails after switching

Restore the previous JDK path first. Review application compatibility, JVM options, removed modules, dependencies, and service logs before retrying. A successful java -version check does not prove the application supports Java 25.

Java 25 source and support lifecycle

OpenJDK's JDK 25 project page identifies Java 25 as an LTS release. The support period, update channel, binaries, and commercial terms depend on the distribution or vendor. Record that choice in the server's software inventory and review it before the selected lifecycle ends.

Ready to run Java 25 on a Virtarix Ubuntu VPS?

Start small for Java development or choose more headroom for staging and production services. Virtarix provides self-managed infrastructure with root access, NVMe storage, IPv4 + IPv6, one included backup, and one included snapshot.

VPS S

For small sites, dev servers and Docker

$ 5 .50 /month
  • 3 cores
  • 6 GB
  • 50 GB NVMe
  • Unlimited
Get It Now
BEST SELLER

VPS M

For growing apps, websites and staging

$ 11 .40 /month
  • 6 cores
  • 16 GB
  • 100 GB NVMe
  • Unlimited
Get It Now
Peter French
About the Author Peter Frenchis the Managing Director at Virtarix, with over 17 years in the tech industry. He has co-founded a cloud storage business, led strategy at a global cloud computing leader, and driven market growth in cybersecurity and data protection.