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

Last updated Wednesday, March 4, 2026 10:32 am 11 min read

Scoped values for thread-safe data sharing, a key derivation function API, and compact source files that eliminate boilerplate class declarations all shipped as finalized features in OpenJDK 25. As the latest LTS release with community support through September 2033, it gives new projects the longest maintenance runway of any current Java version. You can install OpenJDK 25 on Debian 13 directly from the default repositories, while Debian 12 and 11 users get the same version through Eclipse Temurin builds from the Adoptium project.

Install OpenJDK 25 on 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.

Refresh your package index before installing to pick up the latest available versions:

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.

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

Debian 13 carries these OpenJDK 25 packages:

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 OpenJDK 25 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.

For server environments without a graphical display, use the headless variants instead:

sudo apt install openjdk-25-jdk-headless

Verify the OpenJDK 25 Installation

Confirm Java is accessible by checking the installed version:

java --version

The version string identifies this as the Debian-packaged build:

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 builds from the Adoptium project work on all supported Debian releases, including Debian 13, 12, and 11. This method adds the Adoptium APT repository so future updates arrive through your regular apt upgrade workflow.

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 (see the curl command guide for more options). 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

Testing the full compile-and-run cycle catches issues that version checks alone miss.

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!

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

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 Debian’s backports repository 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 OpenJDK 25 Removal

After removal, confirm no OpenJDK 25 installation remains:

java --version

If no other Java versions are installed, the shell reports the command is missing:

bash: java: command not found

If other Java versions remain, the output shows whichever version is now active instead.

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.

Frequently Asked Questions About OpenJDK 25 on Debian

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.

What is the default Java version on Debian 13, 12, and 11?

Debian 13 Trixie ships OpenJDK 21 as the default-jdk meta-package dependency, with OpenJDK 25 available as a separate package. Debian 12 Bookworm includes OpenJDK 17 only. Debian 11 Bullseye provides OpenJDK 11 and 17. Neither Debian 12 nor 11 carries OpenJDK 25 in their default repositories.

Conclusion

OpenJDK 25 is ready to go on Debian. Version switches work through update-alternatives, and JAVA_HOME points where build tools expect. Set up Apache Maven on Debian for dependency management next, or add Git on Debian for version control alongside your Java projects.

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 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 currently allowed:

You type Result
<code>command</code> command
<strong>bold</strong> bold
<em>italic</em> italic
<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: