How to Install OpenJDK 25 on Debian (13, 12, 11)

Last updated February 8, 2026 5:12 pm Joshua James 11 min read

OpenJDK 25 is a Long-Term Support release of the free, open-source Java Development Kit. It finalizes scoped values for thread-safe data sharing, introduces a key derivation function API for cryptographic operations, and brings module import declarations and compact source files to production. Community support runs through at least September 2033, making it the latest stable LTS option for new projects. This guide covers how to install OpenJDK 25 on Debian 13, 12, and 11, manage multiple Java versions, and verify your setup.

Choose Your OpenJDK 25 Installation Method for Debian

Two installation methods are available, each with different version scope and update characteristics:

MethodSourceUpdatesBest For
Debian APT (Debian 13 only)Debian ReposVia apt upgradeDebian 13 Trixie users; simplest setup, no external repositories needed
Eclipse TemurinAdoptiumVia apt upgradeAll Debian versions; TCK-certified, AQAvit-verified builds with faster security patches

For Debian 12 Bookworm and Debian 11 Bullseye users, Eclipse Temurin is the only option because Debian’s default repositories on those releases do not include OpenJDK 25 packages. Debian 13 Trixie users can choose either method; the APT approach is simpler, while Temurin provides enterprise-quality builds with potentially faster security patch releases.

Update Debian Before OpenJDK 25 Installation

Refresh your package index before installing new software to ensure you receive the latest available versions and avoid dependency conflicts:

sudo apt update && sudo apt upgrade

This guide uses sudo for commands that need root privileges. If your user is not in the sudoers file yet, run the commands as root or follow the guide on how to add a user to sudoers on Debian.

The first part downloads current package information from all configured repositories, while the second upgrades installed packages to their newest versions.

Install OpenJDK 25 via Debian APT (Debian 13 Trixie)

Debian 13 Trixie includes OpenJDK 25 in its default repositories alongside OpenJDK 21, which remains the default-jdk dependency. No external repositories are required. Start by listing the available OpenJDK 25 packages:

apt-cache search openjdk-25

The output lists OpenJDK 25 packages available in the repository:

openjdk-25-jdk - OpenJDK Development Kit (JDK)
openjdk-25-jdk-headless - OpenJDK Development Kit (JDK) (headless)
openjdk-25-jre - OpenJDK Java runtime, using Hotspot JIT
openjdk-25-jre-headless - OpenJDK Java runtime, using Hotspot JIT (headless)
openjdk-25-source - OpenJDK Development Kit (JDK) source files
openjdk-25-doc - OpenJDK Development Kit (JDK) documentation
openjdk-25-demo - Java runtime based on OpenJDK (demos and examples)

The “headless” variants exclude graphical libraries and are designed for servers or CI/CD systems without a display. Choose headless packages if you are building Docker containers on Debian or running on a server without a GUI.

Install JRE or JDK

Your choice depends on whether you need to run Java applications only or also develop them. The Java Runtime Environment (JRE) provides the minimum required to execute Java programs:

sudo apt install openjdk-25-jre

For development work, compiling source code, or using build tools like Apache Maven on Debian, install the full Java Development Kit instead. The JDK includes the JRE plus development utilities such as the Java compiler, debugger, and documentation tools:

sudo apt install openjdk-25-jdk

When in doubt, install the JDK. It includes everything from the JRE while adding development tools you may need later. The additional disk space is minimal compared to the flexibility gained.

Verify the Installation

Confirm Java is accessible by checking the installed version:

java --version

The output confirms the Debian-packaged OpenJDK 25 build is installed and active:

openjdk 25.0.2 2026-01-20
OpenJDK Runtime Environment (build 25.0.2+10-Debian-1deb13u2)
OpenJDK 64-Bit Server VM (build 25.0.2+10-Debian-1deb13u2, mixed mode, sharing)

If you installed the JDK, also verify that the Java compiler is available:

javac --version
javac 25.0.2

Install Eclipse Temurin 25 on Debian via Adoptium APT

Eclipse Temurin is an enterprise-quality OpenJDK distribution from the Adoptium project. These builds are TCK-certified for Java compatibility and pass the AQAvit verification suite, providing consistent behavior across platforms. This method works on all supported Debian releases and adds the Adoptium APT repository for automatic updates.

Install Prerequisites for the Adoptium Repository

The repository setup requires curl to download the GPG key and gpg to convert it into the binary format APT expects. Install both if they are not already present:

sudo apt install curl gpg

Import the Adoptium GPG Key

Download and store the Adoptium repository signing key. This key verifies that packages originate from official Adoptium infrastructure:

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

The -fsSL flags tell curl to fail silently on HTTP errors, suppress progress output, and follow redirects. The gpg --dearmor step converts the ASCII-armored key into the binary format that APT requires.

Add the Adoptium Repository

Create the repository configuration file using the DEB822 format. The command below automatically detects your Debian codename and system architecture:

cat <<EOF | sudo tee /etc/apt/sources.list.d/adoptium.sources
Types: deb
URIs: https://packages.adoptium.net/artifactory/deb
Suites: $(. /etc/os-release && echo "$VERSION_CODENAME")
Components: main
Architectures: $(dpkg --print-architecture)
Signed-By: /usr/share/keyrings/adoptium.gpg
EOF

The $(. /etc/os-release && echo "$VERSION_CODENAME") expression reads your Debian release codename (trixie, bookworm, or bullseye) directly from the system, so this command works identically across all supported Debian versions.

Refresh the package index to include the newly added repository:

sudo apt update

Install Temurin 25

Install the Eclipse Temurin 25 JDK package from the Adoptium repository:

sudo apt install temurin-25-jdk

Adoptium also provides temurin-25-jre if you only need the runtime environment without development tools.

Verify the Temurin Installation

Check the installed version to confirm Temurin is active:

java --version

The output shows the Temurin build identifier with the “LTS” designation:

openjdk 25.0.2 2026-01-20 LTS
OpenJDK Runtime Environment Temurin-25.0.2+10 (build 25.0.2+10-LTS)
OpenJDK 64-Bit Server VM Temurin-25.0.2+10 (build 25.0.2+10-LTS, mixed mode, sharing)

Update Temurin to the Latest Version

Temurin receives updates through the Adoptium APT repository. To check for and install the latest version:

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

If Temurin 25 is already at the latest version, APT reports “temurin-25-jdk is already the newest version” and exits without changes.

Manage Multiple Java Versions on Debian

Development environments often require multiple Java versions for different projects. Debian’s update-alternatives system manages symlinks in /usr/bin/, allowing you to switch between installed versions without modifying PATH variables or manually creating symlinks.

Switch the Default Java Runtime

To view all installed Java versions and interactively select the system default:

sudo update-alternatives --config java

The command displays a numbered list of available Java installations. If multiple versions are installed, the output looks similar to:

There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                         Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-25-openjdk-amd64/bin/java   2511      auto mode
  1            /usr/lib/jvm/java-21-openjdk-amd64/bin/java   2111      manual mode
  2            /usr/lib/jvm/java-25-openjdk-amd64/bin/java   2511      manual mode

Press <enter> to keep the current choice[*], or type selection number:

Type the number corresponding to your preferred Java version and press Enter. The asterisk marks the currently active selection. Confirm the change by running java --version again.

Switch the Default Java Compiler

When using multiple JDK versions, also switch the Java compiler to match the runtime. Compiling with one Java version while running on another can cause bytecode compatibility issues:

sudo update-alternatives --config javac

Select the same version number you chose for the runtime. Both commands return immediately to the shell prompt after making your selection.

Configure the JAVA_HOME Environment Variable

Build tools, IDEs, and application servers frequently require the JAVA_HOME environment variable to locate your Java installation. To identify the installation path of your currently active Java version:

dirname $(dirname $(readlink -f $(which java)))

With the Debian APT installation of OpenJDK 25 active on a 64-bit system, this returns:

/usr/lib/jvm/java-25-openjdk-amd64

If you installed Eclipse Temurin instead, the path is /usr/lib/jvm/temurin-25-jdk-amd64. On ARM64 systems (such as Raspberry Pi or AWS Graviton instances), the directory name ends with -arm64 instead of -amd64. Always use the dirname command above to detect the correct path for your architecture and installation method.

Add the export to your ~/.bashrc file to set JAVA_HOME for the current user. Using command substitution detects the correct path automatically, regardless of whether you installed via Debian APT or Temurin:

echo "export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java))))" >> ~/.bashrc
source ~/.bashrc

Verify the variable is configured correctly:

echo $JAVA_HOME
/usr/lib/jvm/java-25-openjdk-amd64

Test OpenJDK 25 with a Sample Java Program on Debian

Verifying your installation goes beyond checking version numbers. Compiling and running a test program confirms the full toolchain works correctly and demonstrates Java 25 features in action.

Create a Test Program

Create a new Java source file:

nano Hello.java

Add the following code, which uses Java 25’s module import declarations and compact source file features:

import module java.base;

void main() {
    var javaVersion = System.getProperty("java.version");
    var osName = System.getProperty("os.name");

    System.out.println("Hello from OpenJDK 25!");
    System.out.println("Running Java " + javaVersion + " on " + osName);
    System.out.println("Using compact source file syntax - no class declaration needed!");
}

Save the file by pressing Ctrl+O, then Enter, then exit nano with Ctrl+X.

Compile and Run the Program

Compile the source file into Java bytecode:

javac Hello.java

Successful compilation produces no output and creates a Hello.class file in the current directory. If the compilation fails, verify that OpenJDK 25 is the active version using javac --version.

Execute the compiled program:

java Hello

Expected output:

Hello from OpenJDK 25!
Running Java 25.0.2 on Linux
Using compact source file syntax - no class declaration needed!

This output confirms your OpenJDK 25 installation compiles and executes Java code correctly, including the finalized compact source file syntax that eliminates boilerplate class declarations for simple programs.

Compare OpenJDK LTS Releases for Debian

Picking the right Java version affects long-term maintenance and access to language features. The table below compares current LTS releases to help you match your project’s requirements with the appropriate version.

Java VersionLTS Support UntilChoose It WhenTrade-offs
OpenJDK 8December 2030 (community)Legacy applications, older frameworks like Spring 4.x, or vendor-certified deployments requiring Java 8Missing modern language features (no var, no records, no virtual threads); some libraries dropping Java 8 support
OpenJDK 11September 2027 (community)Legacy enterprise applications, older frameworks requiring Java 11 as minimum, or vendor-certified deploymentsMissing modern features (no virtual threads, no records, no pattern matching); some libraries dropping Java 11 support
OpenJDK 17September 2029 (community)Spring Boot 3.x, Jakarta EE 10+, or workloads benefiting from records and sealed classesLacks virtual threads and scoped values from newer releases
OpenJDK 21September 2031 (community)High-concurrency applications using virtual threads, projects needing structured concurrency previewsScoped values still in preview; missing finalized features from Java 25
OpenJDK 25September 2033 (community)New projects, applications requiring finalized scoped values, key derivation APIs, or the latest stable LTS featuresNewest LTS release; verify framework compatibility before production migration

OpenJDK 25 suits new projects, applications that benefit from finalized scoped values for thread-safe data sharing, and teams wanting access to the latest stable language improvements. If your project depends on frameworks that have not yet certified Java 25 support, consider OpenJDK 21 as a stable alternative until your stack is ready.

Troubleshoot Common OpenJDK 25 Issues on Debian

This section addresses problems you may encounter when installing or using OpenJDK 25 on Debian.

OpenJDK 25 Package Not Found on Debian 12 or Older

If apt install openjdk-25-jdk fails with “Unable to locate package,” your Debian version does not include OpenJDK 25 in its default repositories. Debian 12 Bookworm ships OpenJDK 17 as its newest available version, and Debian 11 Bullseye tops out at OpenJDK 17 as well. The package is not available through backports for either release.

Confirm your Debian version to verify this is the cause:

cat /etc/os-release | grep -E "^(PRETTY_NAME|VERSION_CODENAME)"

On Debian 12 Bookworm, the output looks like:

PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
VERSION_CODENAME=bookworm

If the output shows bookworm or bullseye, use the Eclipse Temurin method from the Adoptium repository instead. Temurin provides OpenJDK 25 packages for all supported Debian versions.

Wrong Java Version Active After Installation

If java --version reports a different version than expected, multiple Java versions exist on your system with a higher priority assigned to another version. List available alternatives to fix this:

sudo update-alternatives --config java

Select the entry corresponding to OpenJDK 25 and confirm your selection. Also update the compiler using sudo update-alternatives --config javac to maintain consistency between runtime and compiler.

JAVA_HOME Not Recognized by Build Tools

Build tools failing with “JAVA_HOME is not defined” or pointing to an incorrect path means the environment variable needs configuration. Identify the correct path for your installation:

dirname $(dirname $(readlink -f $(which java)))

Add the export statement to your shell configuration file using the path from the command above:

echo "export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java))))" >> ~/.bashrc
source ~/.bashrc

Using command substitution here automatically detects the correct path regardless of whether you installed via Debian APT or Temurin. Verify the variable is set by running echo $JAVA_HOME.

Bytecode Version Mismatch Errors

Errors mentioning “unsupported major.minor version” or “class file version X.Y” occur when code compiled with a newer Java version runs on an older JRE. Verify your compiler and runtime versions match:

java --version
javac --version

Both commands should report Java 25. If they differ, align them using sudo update-alternatives --config for both java and javac.

Remove OpenJDK 25 from Debian

If you no longer need OpenJDK 25, use the appropriate removal commands based on your installation method.

Remove Debian APT OpenJDK

Remove the OpenJDK 25 packages installed from Debian’s default repositories and clean up unused dependencies:

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

Remove Eclipse Temurin

Remove Eclipse Temurin 25 installed from the Adoptium repository:

sudo apt remove temurin-25-jdk
sudo apt autoremove

Optionally remove the Adoptium repository and GPG key if you no longer need any Temurin packages:

sudo rm /etc/apt/sources.list.d/adoptium.sources
sudo rm /usr/share/keyrings/adoptium.gpg
sudo apt update

Verify Removal

After removal, confirm no OpenJDK 25 installation remains:

java --version

If no other Java versions are installed, this command returns “command not found.” If other versions remain, the output shows which Java version is now active.

If you configured JAVA_HOME in your ~/.bashrc file, remember to update or remove that export line after uninstalling OpenJDK 25. Applications relying on JAVA_HOME will fail if the path points to a removed installation.

Is OpenJDK 25 an LTS release?

Yes. OpenJDK 25 is a Long-Term Support release with community support through at least September 2033. Most vendors, including Eclipse Adoptium, designate it as LTS, meaning it receives security patches and bug fixes for years after the initial release. This makes it suitable for production workloads that need long-term stability.

Can I install OpenJDK 25 on Debian 12 Bookworm or Debian 11 Bullseye?

Not from Debian’s default repositories. Debian 12 only includes OpenJDK 17 and Debian 11 includes OpenJDK 11 and 17. Backports do not carry OpenJDK 25 for either release. To get OpenJDK 25 on these versions, add the Eclipse Adoptium repository and install the temurin-25-jdk package, which supports Debian 11, 12, and 13.

What is the difference between OpenJDK and Eclipse Temurin?

OpenJDK is the open-source Java Development Kit project that produces the reference implementation of Java SE. Eclipse Temurin is a specific distribution of OpenJDK built by the Adoptium project. Temurin builds are TCK-certified for Java compatibility and pass the AQAvit quality verification suite. The core Java functionality is identical; Temurin adds enterprise-grade testing and often delivers security patches faster than distribution-packaged OpenJDK.

Conclusion

You have installed OpenJDK 25 on Debian and verified the complete toolchain works correctly. The update-alternatives system handles clean version switching when multiple Java installations coexist, and configuring JAVA_HOME ensures compatibility with build tools and application servers. For Java development workflows, consider pairing this installation with Apache Maven on Debian for dependency management and project builds, or set up Git on Debian for version control alongside your Java environment.

Found this guide useful?

Support LinuxCapable to keep tutorials free and up to date.

Buy me a coffee Buy 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:

You type Result
<code>command</code> command
<pre>block of code</pre> code block
<strong>bold</strong> bold
<em>italic</em> italic
<a href="URL">link</a> link
<blockquote>quote</blockquote> quote block

Leave a Comment

We read and reply to every comment — let us know how we can help or improve this guide.

Let us know you are human: