How to Install Temurin on Debian

Install Eclipse Temurin on Debian 11, 12, or 13 with the Adoptium APT repository, a manual .tar.gz under /opt, or update-alternatives. Switch JDKs with update-java-alternatives, set JAVA_HOME, verify with java -version, and uninstall cleanly.

Published

Updated

Read time 7 min read

Reviewed byDeepak Prasad

How to Install Temurin on Debian

Eclipse Temurin is the OpenJDK distribution built by Eclipse Adoptium—Java SE TCK-tested, widely used in CI and production. On Debian you can install it from the official Adoptium APT repository, unpack a .tar.gz release, and register it with update-alternatives when you need a fixed path under /opt.

This guide covers install Temurin on Debian for Debian 11 (Bullseye), 12 (Bookworm), and 13 (Trixie): add the Adoptium Linux packages repo, install temurin-21-jdk (and other versions), switch defaults with update-java-alternatives, set JAVA_HOME, test compile/run, update, and uninstall. I ran every path on Debian 13 and kept real terminal output below.

Tested on: Debian 13 (trixie); kernel 6.12.94+deb13-amd64; amd64; Temurin 21.0.11+10 via APT and tarball.

NOTE
Temurin and Debian OpenJDK can coexist. Install only one as the system default unless you deliberately manage alternatives. IDE bundles (for example Android Studio) often ship their own JBR and do not need a separate Temurin install for the IDE alone.

Choose an install method

Method Best for Example on test host
Adoptium APT (temurin-21-jdk) Most readers; automatic update-java-alternatives hooks 21.0.11+10 from packages.adoptium.net
Manual .tar.gz Pinning a path under /opt, air-gapped copies, no third-party repo Same 21.0.11+10 build from Adoptium API
Debian openjdk-21-jdk Staying on Debian main only (not Temurin, but common alternative) 21.0.11+10-1~deb13u2 from deb.debian.org

Package names follow Adoptium’s schema: temurin-<version>-jdk (for example temurin-8-jdk, temurin-17-jdk, temurin-21-jdk, temurin-25-jdk). See supported platforms and the deb package tree for your codename.


Prerequisites

  • Debian 11, 12, or 13 on amd64 (other arches appear in Adoptium metadata when published).
  • sudo for repository setup and package installs.
  • wget or curl and gpg for the Adoptium signing key.
  • Disk space: a JDK install is roughly 180–400 MB depending on version and dependencies.

Check what Debian already offers before adding Adoptium:

bash
. /etc/os-release && echo "$PRETTY_NAME ($VERSION_CODENAME)"
java -version 2>&1 || echo "java: not installed"
apt-cache policy default-jdk openjdk-21-jdk temurin-21-jdk 2>/dev/null | head -20

On a clean trixie host before Adoptium:

text
Debian GNU/Linux 13 (trixie) (trixie)
--: line 1: java: command not found
default-jdk:
  Candidate: 2:1.21-76
openjdk-21-jdk:
  Candidate: 21.0.11+10-1~deb13u2

temurin-* candidates appear only after you add the Adoptium repository.


Install Temurin from the Adoptium APT repository

Official steps are documented on Adoptium — Linux (RPM/DEB/APK) installer packages. Repository URLs under packages.adoptium.net/artifactory/ are for apt configuration—they may return 404 in a browser; browse packages at https://packages.adoptium.net/ui/native/deb/dists/ instead.

Add the signing key and repository

bash
sudo apt install -y wget apt-transport-https gpg
wget -qO - https://packages.adoptium.net/artifactory/api/gpg/key/public \
  | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/adoptium.gpg > /dev/null
echo "deb https://packages.adoptium.net/artifactory/deb \
  $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" \
  | sudo tee /etc/apt/sources.list.d/adoptium.list
sudo apt update
apt-cache policy temurin-21-jdk | head -10
text
deb https://packages.adoptium.net/artifactory/deb trixie main
Get:7 https://packages.adoptium.net/artifactory/deb trixie InRelease [7,503 B]
temurin-21-jdk:
  Candidate: 21.0.11.0.0+10-1
     21.0.11.0.0+10-1 500
        500 https://packages.adoptium.net/artifactory/deb trixie/main amd64 Packages

On Bookworm or Bullseye, the awk line expands to bookworm or bullseye automatically—no manual edit when /etc/os-release is standard.

Install a Temurin JDK

Replace 21 with the major you need (17, 21, 25, etc.):

bash
sudo apt install -y temurin-21-jdk
java -version
javac -version
update-java-alternatives --list
text
openjdk version "21.0.11" 2026-04-21 LTS
OpenJDK Runtime Environment Temurin-21.0.11+10 (build 21.0.11+10-LTS)
OpenJDK 64-Bit Server VM Temurin-21.0.11+10 (build 21.0.11+10-LTS, mixed mode, sharing)
javac 21.0.11
temurin-21-jdk-amd64           2111       /usr/lib/jvm/temurin-21-jdk-amd64

The .deb registers java, javac, and related tools through update-alternatives—the same integration described for Ubuntu on Ask Ubuntu — Temurin with update-alternatives.

IMPORTANT
Adoptium is a third-party repository separate from the Debian project. Review Eclipse Adoptium and your org’s policy before adding sources.list entries on production servers—the same caution you would apply to any external APT source.

Install Temurin from a release archive

When you do not want an APT repository, download a .tar.gz from Adoptium—either from Temurin releases or the REST API:

bash
curl -sL 'https://api.adoptium.net/v3/assets/latest/21/hotspot?architecture=x64&image_type=jdk&os=linux&vendor=eclipse' \
  | python3 -c "import sys,json; d=json.load(sys.stdin)[0]; print(d['binary']['package']['link'])"

Example URL returned on the test host:

text
https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.11%2B10/OpenJDK21U-jdk_x64_linux_hotspot_21.0.11_10.tar.gz

Download, extract under /opt, and test the bundled binaries:

bash
cd /tmp
wget -q --show-progress 'https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.11%2B10/OpenJDK21U-jdk_x64_linux_hotspot_21.0.11_10.tar.gz'
sudo mkdir -p /opt/temurin-21
sudo tar -xzf OpenJDK21U-jdk_x64_linux_hotspot_21.0.11_10.tar.gz -C /opt/temurin-21 --strip-components=1
/opt/temurin-21/bin/java -version
text
openjdk version "21.0.11" 2026-04-21 LTS
OpenJDK Runtime Environment Temurin-21.0.11+10 (build 21.0.11+10-LTS)
OpenJDK 64-Bit Server VM Temurin-21.0.11+10 (build 21.0.11+10-LTS, mixed mode, sharing)

Register the manual install with update-alternatives

APT packages use update-java-alternatives. Tarball installs use update-alternatives directly (manual pattern used across many guides):

bash
sudo update-alternatives --install /usr/bin/java java /opt/temurin-21/bin/java 2112
sudo update-alternatives --install /usr/bin/javac javac /opt/temurin-21/bin/javac 2112
sudo update-alternatives --set java /opt/temurin-21/bin/java
java -version
readlink -f "$(which java)"
text
update-alternatives: using /opt/temurin-21/bin/java to provide /usr/bin/java (java) in manual mode
openjdk version "21.0.11" 2026-04-21 LTS
/opt/temurin-21/bin/java

Use a higher priority number (here 2112) when you want the manual build to win over an existing 2111 APT JDK.


Switch between multiple JDK installations

After installing both Temurin and Debian OpenJDK for comparison:

bash
sudo apt install -y openjdk-21-jdk
update-java-alternatives --list
text
java-1.21.0-openjdk-amd64      2111       /usr/lib/jvm/java-1.21.0-openjdk-amd64
temurin-21-jdk-amd64           2111       /usr/lib/jvm/temurin-21-jdk-amd64

Set the default JVM:

bash
sudo update-java-alternatives --set temurin-21-jdk-amd64
java -version 2>&1 | head -1
text
openjdk version "21.0.11" 2026-04-21 LTS

Switch to Debian’s build:

bash
sudo update-java-alternatives --set java-1.21.0-openjdk-amd64
java -version 2>&1 | head -3
text
openjdk version "21.0.11" 2026-04-21
OpenJDK Runtime Environment (build 21.0.11+10-1-deb13u2-Debian)
OpenJDK 64-Bit Server VM (build 21.0.11+10-1-deb13u2-Debian, mixed mode, sharing)

For tarball-only installs mixed with APT JDKs, use sudo update-alternatives --config java when both are registered.


Set JAVA_HOME

Point JAVA_HOME at the JVM root—not the bin directory:

bash
export JAVA_HOME=/usr/lib/jvm/temurin-21-jdk-amd64
export PATH="$JAVA_HOME/bin:$PATH"
java -version

Persist for all users:

bash
echo 'export JAVA_HOME=/usr/lib/jvm/temurin-21-jdk-amd64' | sudo tee /etc/profile.d/temurin.sh
echo 'export PATH="$JAVA_HOME/bin:$PATH"' | sudo tee -a /etc/profile.d/temurin.sh

For /opt/temurin-21, use export JAVA_HOME=/opt/temurin-21 instead.


Verify with a sample Java program

bash
mkdir -p ~/javatest
cat > ~/javatest/Hello.java <<'EOF'
public class Hello {
  public static void main(String[] args) {
    System.out.println("Hello from Temurin on Debian");
  }
}
EOF
javac ~/javatest/Hello.java
java -cp ~/javatest Hello
text
Hello from Temurin on Debian

If javac: command not found, you installed a JRE-only package or PATH omits $JAVA_HOME/bin.


Temurin vs Debian OpenJDK (quick reference)

Eclipse Temurin Debian OpenJDK
Package temurin-21-jdk (Adoptium repo) openjdk-21-jdk (Debian main)
JVM path /usr/lib/jvm/temurin-21-jdk-amd64 /usr/lib/jvm/java-1.21.0-openjdk-amd64
Updates apt upgrade after Adoptium publish Debian security/archive
Switch tool update-java-alternatives update-java-alternatives

Debian 13 also ships openjdk-25-jdk in main for the newest OpenJDK line; Temurin temurin-25-jdk is available from Adoptium when you want their build on older suites too.


Update Temurin

bash
sudo apt update
sudo apt install --only-upgrade temurin-21-jdk
java -version

Re-run sudo apt update after Adoptium publishes a new build. For tarball installs, download the newer archive, extract to a new directory, adjust update-alternatives, and remove the old tree.

List installed JDK packages with list installed packages on Debian or:

bash
dpkg -l 'temurin-*' 'openjdk-*-jdk' 2>/dev/null | grep ^ii

Uninstall Temurin

APT package

bash
sudo apt remove --purge temurin-21-jdk
sudo apt autoremove

Remove the repository when finished:

bash
sudo rm -f /etc/apt/sources.list.d/adoptium.list /etc/apt/trusted.gpg.d/adoptium.gpg
sudo apt update

Manual /opt install

bash
sudo update-alternatives --remove java /opt/temurin-21/bin/java
sudo update-alternatives --remove javac /opt/temurin-21/bin/javac
sudo rm -rf /opt/temurin-21
rm -f /tmp/OpenJDK21U-jdk_x64_linux_hotspot_21.0.11_10.tar.gz

If update-alternatives --remove reports the link is still in use, --set another JDK first (for example sudo update-java-alternatives --set java-1.21.0-openjdk-amd64).


Troubleshooting

Symptom Likely cause Fix
temurin-21-jdk has no Candidate Adoptium repo not added or wrong codename Re-run the adoptium.list echo line; confirm bookworm / bullseye / trixie in the file
400 Bad Request fetching .deb Stale apt metadata or past installer issue #766 on some suites sudo apt update; verify codename; try again or use the tarball path
java: command not found after install PATH or alternatives not set update-java-alternatives --list; which java; set JAVA_HOME
javac: command not found JRE-only install Install temurin-XX-jdk, not a runtime-only variant
Wrong vendor in java -version Multiple JDKs installed sudo update-java-alternatives --set temurin-21-jdk-amd64 or update-alternatives --config java
Browser 404 on artifactory URL Normal—repos are for package managers Use Adoptium installation docs or the API download above

References


Summary

Install Temurin on Debian by adding the Adoptium APT repository, running sudo apt install temurin-21-jdk, and confirming with java -version. For a fixed /opt layout, unpack the official .tar.gz and wire it with update-alternatives. Use update-java-alternatives when several APT JDKs are installed, set JAVA_HOME to the JVM directory, and remove the package or tarball when you no longer need it.


Frequently Asked Questions

1. How do I install Temurin on Debian?

Add the Adoptium APT repository from adoptium.net/installation/linux, run sudo apt update, then sudo apt install temurin-21-jdk (or temurin-17-jdk, temurin-25-jdk). Verify with java -version. For a manual install, download a Temurin .tar.gz and register it with update-alternatives.

2. What is the difference between Temurin and OpenJDK on Debian?

OpenJDK packages (openjdk-21-jdk) come from Debian main. Eclipse Temurin is Adoptium’s TCK-tested OpenJDK build packaged as temurin-XX-jdk from packages.adoptium.net. Both provide java and javac; pick one default with update-java-alternatives.

3. Which Temurin package name should I install on Debian?

Adoptium uses temurin--jdk for the full JDK (for example temurin-21-jdk). Runtime-only installs use temurin-21-jre or temurin-21-jre-headless on RPM-based distros; Debian .deb JDK packages are the usual choice for development.

4. Does the Adoptium repository support Debian 12 Bookworm?

Yes—use your VERSION_CODENAME (bookworm, bullseye, or trixie) in the adoptium.list line. If apt install returns 400 Bad Request, refresh apt metadata, confirm the codename in /etc/apt/sources.list.d/adoptium.list, and check github.com/adoptium/installer/issues for repository fixes.

5. How do I switch between multiple Java versions on Debian?

For APT-installed JDKs, run sudo update-java-alternatives --list and sudo update-java-alternatives --set temurin-21-jdk-amd64. For manual /opt installs, use sudo update-alternatives --config java. Set JAVA_HOME to the JVM directory, for example /usr/lib/jvm/temurin-21-jdk-amd64.

6. What does default-jdk install on Debian?

default-jdk is a metapackage, not Temurin. On Debian 13 it pulls OpenJDK 21; on Debian 12 OpenJDK 17; on Debian 11 OpenJDK 11. Install temurin-21-jdk explicitly when you want Adoptium’s build.

7. How do I set JAVA_HOME for Temurin on Debian?

Export JAVA_HOME=/usr/lib/jvm/temurin-21-jdk-amd64 (adjust the version). Add export PATH="$JAVA_HOME/bin:$PATH" to ~/.profile or /etc/profile.d/temurin.sh. Confirm with echo $JAVA_HOME and java -version.

8. How do I uninstall Temurin from Debian?

For APT: sudo apt remove --purge temurin-21-jdk. Remove /etc/apt/sources.list.d/adoptium.list and /etc/apt/trusted.gpg.d/adoptium.gpg if you added the repo. For manual installs: update-alternatives --remove java /opt/.../bin/java, then delete the directory.
Omer Cakmak

Linux Administrator

Highly skilled at managing Debian, Ubuntu, CentOS, Oracle Linux, and Red Hat servers. Proficient in bash scripting, Ansible, and AWX central server management, he handles server operations on …