How to Install OpenJDK 25 on Debian 13, 12 and 11

Install OpenJDK 25 on Debian 13, 12, and 11 via APT or Eclipse Temurin. Covers version switching, JAVA_HOME, and troubleshooting.

Last updatedAuthorJoshua JamesRead time10 minGuide typeDebian

Java 25 is the current LTS branch for new long-lived projects, especially when you want finalized scoped values, module imports, and compact source files without waiting for the next runtime cycle. You can install OpenJDK 25 on Debian 13 directly from Debian’s default repositories, while Debian 12 and Debian 11 need Eclipse Temurin packages from Adoptium.

The OpenJDK JDK 25 project lists JDK 25 as a general-availability release and notes that most vendors treat it as long-term support. Vendor support windows still vary, so the Temurin sections below follow Adoptium’s current package and support policy rather than assuming one universal Java 25 end date.

Install OpenJDK 25 on Debian

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

MethodSourceRelease ScopeUpdatesBest Fit
Debian APTDebian package sourcesDebian 13 (trixie)Through normal Debian security and package updatesDebian 13 systems that prefer distro-packaged OpenJDK without an external repository
Eclipse TemurinAdoptium Linux packagesDebian 13 (trixie), Debian 12 (bookworm), and Debian 11 (bullseye)Through the Adoptium APT repositoryDebian 12 and 11 systems, or Debian 13 systems that want Adoptium’s TCK-tested Temurin build

Debian 13 (trixie) currently carries openjdk-25-jdk, while Debian 12 (bookworm) and Debian 11 (bullseye) do not. On those older stable releases, the Temurin repository is the practical package-managed path for Java 25.

The default-jdk package does not install Java 25 on any of these Debian releases. Debian 13 resolves it to OpenJDK 21, Debian 12 resolves it to OpenJDK 17, and Debian 11 resolves it to OpenJDK 11, so install the explicit OpenJDK 25 or Temurin 25 package when your application requires Java 25.

OpenJDK is the upstream Java project. Eclipse Temurin is an OpenJDK distribution built by Adoptium, Java SE TCK-tested, and packaged for Debian through Adoptium’s APT repository.

Refresh your package index before installing so APT uses current package metadata:

sudo apt update

Commands that install packages or write APT source files need root privileges. If your account cannot use sudo, run the commands from a root shell or follow how to add a user to sudoers on Debian first.

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 repository is required. List the available OpenJDK 25 packages first:

apt-cache search openjdk-25

Relevant Debian 13 package results include:

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)
openjdk-25-dbg - Java runtime based on OpenJDK (debugging symbols)

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.3 2026-04-21
OpenJDK Runtime Environment (build 25.0.3+9-2-deb13u1-Debian)
OpenJDK 64-Bit Server VM (build 25.0.3+9-2-deb13u1-Debian, mixed mode, sharing)

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

javac --version
javac 25.0.3

Update Debian APT OpenJDK 25 Packages

Debian-packaged OpenJDK 25 receives updates through the normal Debian repositories. Refresh package metadata and upgrade the installed OpenJDK 25 package variant with:

sudo apt update
sudo apt install --only-upgrade openjdk-25-jdk openjdk-25-jre openjdk-25-jdk-headless openjdk-25-jre-headless

APT skips any package from that list that is not installed, so the same command works whether you chose the JDK, JRE, or a headless variant.

Install Eclipse Temurin 25 on Debian via Adoptium APT

Eclipse Temurin builds from the Adoptium project work on Debian 13 (trixie), Debian 12 (bookworm), and Debian 11 (bullseye). This method adds the Adoptium APT repository so future Java 25 updates arrive through your regular package workflow.

Install Prerequisites for the Adoptium Repository

The repository setup needs ca-certificates for HTTPS validation, curl to download the signing key, and gpg to convert that key into the binary format APT expects. Install them before creating the source file:

sudo apt install ca-certificates 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 --yes -o /usr/share/keyrings/adoptium.gpg

The -fsSL flags tell curl to fail on HTTP errors, hide the progress meter while still showing errors, and follow redirects. See the curl command guide for more download options. The Adoptium key is ASCII-armored, so gpg --dearmor --yes stores a binary keyring and allows safe reruns.

Add the Adoptium Repository

Create the repository configuration file using DEB822 format. The command detects your Debian codename and CPU architecture from the local system:

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

The $VERSION_CODENAME value comes from /etc/os-release, so the same block writes trixie, bookworm, or bullseye as needed. The tee command writes the root-owned source file while keeping the shell redirection outside the privileged part.

Refresh the package index to include the newly added repository:

sudo apt update

Confirm APT can see the Temurin 25 package from the new source:

apt-cache policy temurin-25-jdk

Relevant lines on Debian 12 Bookworm include the current Temurin 25 candidate and the Adoptium package source:

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 bookworm/main amd64 Packages

Debian 13 and Debian 11 show the same candidate version with trixie or bullseye in the source line.

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.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)

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 temurin-25-jre

APT upgrades whichever Temurin 25 package is installed and skips the other if it is absent. If Temurin 25 is already current, APT 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 "$(command -v 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. Detect the path from the active java command so it matches 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:

JAVA_HOME_PATH="$(dirname "$(dirname "$(readlink -f "$(command -v java)")")")"
printf '\nexport JAVA_HOME=%s\n' "$JAVA_HOME_PATH" >> ~/.bashrc
. ~/.bashrc

Verify the variable is configured correctly:

printf '%s\n' "$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 compact Java source file that uses Java 25’s module import declarations and instance main method syntax:

cat <<'EOF' > Hello.java
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!");
}
EOF

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

A successful run prints:

Hello from OpenJDK 25!
Running Java 25.0.3 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. These LTS notes use Adoptium’s current Temurin support roadmap, so treat the dates as vendor-specific availability windows rather than universal OpenJDK end dates.

Java VersionTemurin AvailabilityChoose It WhenTrade-offs
OpenJDK 8At least December 2030Legacy applications, older frameworks like Spring 4.x, or vendor-certified deployments requiring Java 8Missing modern language features such as records, pattern matching, and virtual threads
OpenJDK 11At least October 2027Legacy enterprise applications, older frameworks requiring Java 11 as a minimum, or vendor-certified deploymentsMissing newer platform features such as records, pattern matching, and virtual threads
OpenJDK 17At least October 2027Spring Boot 3.x, Jakarta EE 10+, or workloads benefiting from records and sealed classesLacks virtual threads and scoped values from newer releases
OpenJDK 21At least December 2029High-concurrency applications using virtual threads or teams that need the previous LTS baselineScoped values were still preview features in Java 21, and Java 25 adds newer finalized APIs
OpenJDK 25At least September 2031New 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 on Debian 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 on Debian as its newest available default-archive 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.

E: Unable to locate package openjdk-25-jdk

Confirm your Debian version to verify this is the cause:

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

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 Debian 13, Debian 12, and Debian 11.

Temurin 25 Package Not Found After Adding Adoptium

If sudo apt install temurin-25-jdk returns “Unable to locate package,” APT has not ingested the Adoptium source or the source file contains the wrong release codename:

E: Unable to locate package temurin-25-jdk

Refresh the package index and recheck the package candidate:

sudo apt update
apt-cache policy temurin-25-jdk

If no candidate appears, inspect the saved source file:

grep -E "^(URIs|Suites|Components|Architectures|Signed-By):" /etc/apt/sources.list.d/adoptium.sources

The Suites: line must match your Debian codename, such as trixie, bookworm, or bullseye. If the file is missing or uses the wrong codename, rerun the Adoptium source creation step and then repeat sudo apt update.

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.

Build Tool Reports Invalid Source Release 25

Build errors such as “invalid source release: 25” or “release 25 is not found in the system” usually mean your compiler or build tool is still using an older Java release while the project requests Java 25:

error: invalid source release: 25

Check the compiler and JAVA_HOME path:

javac --version
printf '%s\n' "$JAVA_HOME"

A Debian APT install should report Java 25 and the OpenJDK 25 path:

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

If javac reports Java 21, 17, or 11, switch both java and javac with update-alternatives. If JAVA_HOME points at an older directory, update the export and reload your shell before rerunning Maven, Gradle, or another build tool.

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 "$(command -v java)")")"

Add the export statement to your shell configuration file using the detected path:

JAVA_HOME_PATH="$(dirname "$(dirname "$(readlink -f "$(command -v java)")")")"
printf '\nexport JAVA_HOME=%s\n' "$JAVA_HOME_PATH" >> ~/.bashrc
. ~/.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 with printf '%s\n' "$JAVA_HOME".

Bytecode Version Mismatch Errors

Errors mentioning “unsupported major.minor version” or “class file version 69.0” occur when code compiled with Java 25 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:

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

Remove Eclipse Temurin

Remove Eclipse Temurin 25 installed from the Adoptium repository:

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

After either package removal path, preview unused dependencies before deleting them:

sudo apt autoremove --dry-run

If the preview only lists packages you no longer need, remove them with:

sudo apt autoremove

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

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

Verify OpenJDK 25 Removal

After removal, confirm no OpenJDK 25 package remains installed:

dpkg -l openjdk-25-jdk openjdk-25-jre openjdk-25-jdk-headless openjdk-25-jre-headless temurin-25-jdk temurin-25-jre 2>/dev/null | grep '^ii' || echo "No OpenJDK 25 package is installed"

A clean package check prints:

No OpenJDK 25 package is installed

If other Java versions remain, java --version shows whichever runtime 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.

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.

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 more of our fresh Linux tutorials in Top Stories and From your sources 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
<blockquote>quote</blockquote> quote block

Got a Question or Feedback?

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

Verify before posting: