sudo update-alternatives --config java
update-alternatives: error: no alternatives for java

The installed java versions need to be added to update-alternatives:

adding jdk-11 with 10 priority :

sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-11-openjdk-amd64/bin/java 10 

adding jdk-15 with 20 priority (suppose you have extracted the tarball to /usr/lib/jvm/ directory. In your case replace /usr/lib/jvm/jdk-15.0.2/bin/java with /usr/local/bin/jdk-15.0.2/bin/java)

sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-15.0.2/bin/java 20

Check it:

 sudo update-alternatives --list java

/usr/lib/jvm/java-11-openjdk-amd64/bin/java
/usr/lib/jvm/jdk-15.0.2/bin/java

and

sudo update-alternatives --config java

sample output:

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

  Selection    Path                                         Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/jdk-15.0.2/bin/java              20        auto mode
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java   10        manual mode
  2            /usr/lib/jvm/jdk-15.0.2/bin/java              20        manual mode

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

Check the java version, in the above example the default version is jdk-15:

java --version

openjdk 15.0.2 2021-01-19
OpenJDK Runtime Environment (build 15.0.2+7-27)
OpenJDK 64-Bit Server VM (build 15.0.2+7-27, mixed mode, sharing)
Answer from GAD3R on Stack Exchange
๐ŸŒ
Debian
packages.debian.org โ€บ search
Debian -- Package Search Results -- openjdk
sid (unstable) (java): OpenJDK Development Kit (JDK) (headless) 11.0.32~3ea-1: alpha amd64 arm64 armhf i386 ppc64 ppc64el riscv64 s390x sh4 sparc64 x32 11.0.21~4ea-1 [debports]: ia64 11.0.19+7+really11.0.11+9-1+b2 [debports]: m68k
๐ŸŒ
Debian
wiki.debian.org โ€บ Java
Java - Debian Wiki
These cover runtime compatibility and come in two flavours; headless (omits graphical interfaces) and normal. A dependency on javaX-runtime means that the package can work with any runtime which implements version X. Runtimes should provide all virtual packages which they support, so openjdk 6 provides java2-runtime, java5-runtime and java6-runtime.
๐ŸŒ
TecMint
tecmint.com โ€บ home โ€บ debian โ€บ how to install java jdk 21 on debian 12
How to Install Java 21 (JDK) on Debian 12
June 27, 2024 - The easiest way to install Java 21 on Debian 12 is by using the apt package manager as a regular user with sudo privileges and updating the system packages as shown. ... If you want to check if Java is installed, run the command.
Top answer
1 of 2
4
sudo update-alternatives --config java
update-alternatives: error: no alternatives for java

The installed java versions need to be added to update-alternatives:

adding jdk-11 with 10 priority :

sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-11-openjdk-amd64/bin/java 10 

adding jdk-15 with 20 priority (suppose you have extracted the tarball to /usr/lib/jvm/ directory. In your case replace /usr/lib/jvm/jdk-15.0.2/bin/java with /usr/local/bin/jdk-15.0.2/bin/java)

sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-15.0.2/bin/java 20

Check it:

 sudo update-alternatives --list java

/usr/lib/jvm/java-11-openjdk-amd64/bin/java
/usr/lib/jvm/jdk-15.0.2/bin/java

and

sudo update-alternatives --config java

sample output:

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

  Selection    Path                                         Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/jdk-15.0.2/bin/java              20        auto mode
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java   10        manual mode
  2            /usr/lib/jvm/jdk-15.0.2/bin/java              20        manual mode

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

Check the java version, in the above example the default version is jdk-15:

java --version

openjdk 15.0.2 2021-01-19
OpenJDK Runtime Environment (build 15.0.2+7-27)
OpenJDK 64-Bit Server VM (build 15.0.2+7-27, mixed mode, sharing)
2 of 2
0

The answer is rather pretty simple but not very recommended, just set apt to prefer buster-updates's packages, append Debian 11's (Bullseye) repositories to your /etc/sources.list, then force it to install/update the openjdk-17-jdk.

This means that you'll have a FrankenDebian, but it'll still be far better than installing from the sources or from somewhere else.

You can also do this far easier by using a GUI: synaptic.

Edit: I also forgot, but GAD3R is also right about the update-alternatives thing, you may also have to do that too if installing from the packages don't trigger it.

๐ŸŒ
LinuxCapable
linuxcapable.com โ€บ home โ€บ debian โ€บ how to install openjdk 25 on debian 13, 12 and 11
How to Install OpenJDK 25 on Debian 13, 12 and 11 - LinuxCapable
May 11, 2026 - Install OpenJDK 25 on Debian 13, 12, and 11 via APT or Eclipse Temurin. Covers version switching, JAVA_HOME, and troubleshooting.
๐ŸŒ
Debian
packages.debian.org โ€บ sid โ€บ openjdk-17-jdk
Debian -- Details of package openjdk-17-jdk in sid
OpenJDK is a development environment for building applications, applets, and components using the Java programming language.
Top answer
1 of 12
158

Alternatively, you can use adoptopenjdk repository:

wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add -

sudo add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/

sudo apt-get update && sudo apt-get install adoptopenjdk-8-hotspot

https://adoptopenjdk.net/installation.html

2 of 12
80

WARNING: this answer suggest unsupported and dangerous mixing of Debian releases. Follow the advice on your own risk, as it can break the system on upgrades, as explained in http://wiki.debian.org/DontBreakDebian#Don.27t_make_a_FrankenDebian

Package mirror search steps:

  1. In the Search package directories search for openjdk-8-jdk. You can see two results:

    • stretch (oldstable) (java): OpenJDK Development Kit (JDK)
    • sid (unstable) (java): OpenJDK Development Kit (JDK)
  2. Choose stretch repository

  3. Scroll to the Download openjdk-8-jdk section and choose your architecture. For example amd64

  4. Now you can see mirrors list and instructions how to install the package via apt:

    You should be able to use any of the listed mirrors by adding a line to your /etc/apt/sources.list like this:

    deb http://security.debian.org/debian-security stretch/updates main

Installation steps:

  1. Install software source manager

    apt-get update
    apt-get install software-properties-common
    
  2. Add mirror with openjdk-8-jdk

    apt-add-repository 'deb http://security.debian.org/debian-security stretch/updates main'
    apt-get update
    
  3. Install openjdk 8

    apt-get install openjdk-8-jdk
    

Note: You can use steps above to find an official Debian mirror with any other package you want to install

Find elsewhere
๐ŸŒ
DigitalOcean
digitalocean.com โ€บ community โ€บ tutorials โ€บ how-to-install-java-with-apt-on-debian-11
How To Install Java with Apt on Debian 11 | DigitalOcean
September 1, 2022 - By default, Debian 11 includes OpenJDK version 11, which is an open-source variant of the JRE and JDK, and is compatible with Java 11.
๐ŸŒ
Ralph's Open Source Blog
ralph.blog.imixs.com โ€บ 2024 โ€บ 01 โ€บ 24 โ€บ install-open-jdk-11-on-debian-12-bookworm
Install Open JDK 11 on Debian 12 (Bookworm) - Ralph's Open Source Blog
January 24, 2024 - This will make our Debian 12 system only choose the stable packages while updating instead of unstable ones. Now you can install JDK 11 and switch the java version using the ยท $ sudo apt update $ sudo apt install openjdk-11-jdk $ sudo update-alternatives --config java
๐ŸŒ
Debian
tracker.debian.org โ€บ pkg โ€บ openjdk-21
openjdk-21 - Debian Package Tracker
[2026-04-30] Accepted openjdk-21 21.0.11+10-1~deb13u2 (source) into proposed-updates (Debian FTP Masters) (signed by: Moritz Mรผhlenhoff)
๐ŸŒ
Debian
packages.debian.org โ€บ sid โ€บ openjdk-8-jdk
Debian -- Details of package openjdk-8-jdk in sid
OpenJDK is a development environment for building applications, applets, and components using the Java programming language.
๐ŸŒ
Snapcraft
snapcraft.io โ€บ install โ€บ openjdk โ€บ debian
Install OpenJDK on Debian using the Snap Store | Snapcraft
March 17, 2026 - Get the latest version of OpenJDK for on Debian - Current JDK release and early-access builds
๐ŸŒ
LinuxCapable
linuxcapable.com โ€บ home โ€บ debian โ€บ how to install openjdk 17 on debian 13, 12 and 11
How to Install OpenJDK 17 on Debian 13, 12 and 11 - LinuxCapable
May 19, 2026 - Install OpenJDK 17 on Debian 13, 12, and 11 with Debian APT or Temurin. Covers JAVA_HOME, version switching, and removal steps.
๐ŸŒ
ComputingForGeeks
computingforgeeks.com โ€บ home โ€บ install java (openjdk) on debian 13 โ€“ jdk and jre
Install Java 11 (OpenJDK 11) on Debian 12 | 11 | 10 | ComputingForGeeks
February 7, 2025 - In this blog post, you shall learn how to install Oracle Java 11 (OpenJDK 11) on Debian 12/11/10. Java is a widely used programming language for creating Web, mobile, and desktop applications.
๐ŸŒ
Reddit
reddit.com โ€บ r/debian โ€บ will openjdk 21 come to debian 12?
r/debian on Reddit: will OpenJDK 21 come to Debian 12?
October 25, 2024 -

I am guessing and hoping that it will, but is there some way for me to make a more educated guess based on what one can see here?
https://tracker.debian.org/pkg/openjdk-21
and here
https://qa.debian.org/developer.php?login=openjdk-21%40packages.debian.org

๐ŸŒ
ComputingForGeeks
computingforgeeks.com โ€บ home โ€บ install java jdk 21 or openjdk 21 on debian 12/11/10
Install Java JDK 21 or OpenJDK 21 on Debian 12/11/10 [Guide]
March 12, 2024 - Step-by-step guide to java JDK 21 or OpenJDK 21 on Debian 12/11/10. Includes commands, verification, and troubleshooting.
๐ŸŒ
Linuxize
linuxize.com โ€บ home โ€บ java โ€บ how to install java on debian 10 linux
How to Install Java on Debian 10 Linux | Linuxize
February 24, 2020 - OpenJDK 11, the open-source implementation of the Java Platform, is the default Java development and runtime in Debian 10, Buster.
๐ŸŒ
OpenJDK
openjdk.org โ€บ install
OpenJDK: Download and install
If you want to develop Java programs then install the java-1.8.0-openjdk-devel package.
๐ŸŒ
ComputingForGeeks
computingforgeeks.com โ€บ home โ€บ how to install java openjdk and oracle jdk on debian 13 / 12
Install Java OpenJDK and Oracle JDK on Debian 13/12 | ComputingForGeeks
April 19, 2026 - Install OpenJDK 21 LTS, OpenJDK 25, Temurin 17/11, or Oracle JDK 21 on Debian 13 and 12. Set JAVA_HOME, switch defaults, verify with HelloWorld.
๐ŸŒ
OpenJDK Debian 12
marketplace.microsoft.com โ€บ en-us โ€บ marketplace โ€บ apps โ€บ supportedimagesllc1615494954880.openjdk-debian-12
OpenJDK Debian 12
Welcome to the OpenJDK Debian 12, a powerful virtual machine tailored for developers and enterprises seeking a reliable Java Development Kit (JDK) environment on Azure.