Installing Java 17 on Debian 13 and Debian 12
Debian 12 ships OpenJDK 17, Debian 13 no longer does. Here is how to install Java 17 on both, either with apt or through the Adoptium repository with Eclipse Temurin.
Want to install Java 17 on your Debian server? One thing up front: whether a simple apt install is enough depends on your Debian release. Debian 12 (Bookworm) ships OpenJDK 17, Debian 13 (Trixie) does not. This guide shows the right path for both cases.
Requirements
You need SSH access with root privileges (or a user with sudo permissions) on a current Debian system. Debian 13 "Trixie" and Debian 12 "Bookworm" are recommended. Debian 10 reached its end of support in June 2024 and no longer receives regular security updates, so it is not suitable for production use anymore.
This command shows which Debian release you are running:
cat /etc/os-release
Then refresh the package list and install any pending updates:
apt update && apt upgrade -y
Which Debian release ships which Java version?
Debian swaps out the bundled OpenJDK versions with every new major release. A guide that blanket-recommends apt install openjdk-17-jre-headless therefore fails on Debian 13. This overview shows what is actually in the official package sources (as of July 2026):
| Package | Debian 13 | Debian 12 | Debian 11 |
|---|---|---|---|
| openjdk-8-jre-headless | not included | not included | not included |
| openjdk-11-jre-headless | not included | not included | 11.0.31 |
| openjdk-17-jre-headless | not included | 17.0.19 | 17.0.19 |
| openjdk-21-jre-headless | 21.0.11 | not included | not included |
| openjdk-25-jre-headless | 25.0.3 | not included | not included |
You can check whether a package is available on your system at any time:
apt-cache policy openjdk-17-jre-headless
If a version number appears next to "Candidate", you can install right away. If it says (none) there, use the Temurin route further down.
Installing Java 17 on Debian 12
On Debian 12 (and on Debian 11 as well) OpenJDK 17 sits in the official repository. A single command is enough:
apt install openjdk-17-jre-headless -y
The jre-headless variant contains only the runtime without graphical libraries, which makes it the lean and appropriate choice for a server, for example for a Minecraft server or a Java web application.
If you also need a compiler because you build Java applications on the server itself, install the full JDK:
apt install openjdk-17-jdk -y
Installing Java 17 on Debian 13 from the Adoptium repository
Debian 13 no longer contains OpenJDK 17; the bundled version there is Java 21. If your application explicitly requires Java 17, install Eclipse Temurin. It is a freely available OpenJDK build that comes from its own repository and is then updated through apt like any other package.
First install the helper packages and create the directory for repository keys:
apt install -y wget gpg apt-transport-https ca-certificates
mkdir -p /etc/apt/keyrings
Next, download the signing key and add the package source. The sources line points explicitly to this one key via signed-by=, so the key is valid for this repository only:
wget -qO - https://packages.adoptium.net/artifactory/api/gpg/key/public | tee /etc/apt/keyrings/adoptium.asc
echo "deb [signed-by=/etc/apt/keyrings/adoptium.asc] https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | tee /etc/apt/sources.list.d/adoptium.list
apt update
Then install Java 17:
apt install temurin-17-jre -y
If you need a compiler here as well, install temurin-17-jdk instead. The Adoptium repository provides versions 8 through 26 for Debian 13, so you are not tied to whatever your distribution happens to offer. The same package source is available for Debian 12.
Alternative: using the Debian default version
If your application does not require a specific Java version but simply needs a current Java, the metapackage is the most convenient route. It automatically pulls in the version your distribution defines as the default:
apt install default-jre-headless -y
Depending on the Debian release, that gives you the following Java:
| Distribution | Java version via default-jre-headless |
|---|---|
| Debian 13 | Java 21 |
| Debian 12 | Java 17 |
| Debian 11 | Java 11 |
On Debian 12 you therefore get exactly the Java 17 you want, without having to maintain the version number in the package name.
Verifying the installation
Finally, check that the installation worked. Simply query the installed Java version:
java -version
If the output starts with openjdk version "17, Java 17 is set up correctly and ready to use.
Managing several Java versions side by side
If several JDKs are installed on the server, the alternatives system decides which version actually starts when you call java. List all available versions like this:
update-alternatives --list java
Then pick the default version you want interactively from the list:
update-alternatives --config java
If an application also needs the JAVA_HOME environment variable, take the path from that list and add it permanently to /etc/environment:
JAVA_HOME="/usr/lib/jvm/java-17-openjdk-amd64"
Still running Debian 11?
Debian 11 "Bullseye" only receives limited LTS security updates, but it still includes OpenJDK 17. The command is the same as on Debian 12:
apt install openjdk-17-jre-headless -y
Plan an upgrade in the medium term anyway, so that you get regular security updates for all packages again.
Common errors and solutions
"Unable to locate package openjdk-17-jre-headless" on Debian 13: This is not a fault in your installation. Debian 13 simply no longer contains this package. Install Java 17 there through the Adoptium repository, or switch to the bundled Java 21.
The same message on Debian 12: In this case the local package list is outdated or incomplete. Run apt update and check in /etc/apt/sources.list that the main source for your Debian release is listed.
java -version reports a different version: An older Java installation is still registered as the default on the system. Select the version you want with update-alternatives --config java.
Guides that use apt-key: Older posts add third-party sources with apt-key adv. That command has been deprecated since Debian 11, because a key added this way becomes valid for every package source on the system. Current guides place the key in /etc/apt/keyrings/ and reference it from the sources line via signed-by=.
Your application still does not start with Java 17: Some software checks the Java version at startup and requires a specific major version. In that case take a look at the application log, which usually states the exact version required.
Frequently asked questions
Which command installs Java 17 on Debian?
Why does Debian 13 report Unable to locate package openjdk-17-jre-headless?
Which Java version do I get with default-jre-headless?
What is the difference between openjdk-17-jre-headless and openjdk-17-jdk?
How do I set Java 17 as the default version?
2023-2026 KernelHost GmbH. All rights reserved. This guide is protected by copyright. Republishing it on other websites, in whole, in part or in edited form, is not permitted without our written consent. Quoting with a source credit and a link is expressly welcome.

