An easy way be adding java and javac to update-alternatives:

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

Next you will be able to use java and javac commands.

If you have a multiples java, javac versions, use the following command to switch between them:

sudo update-alternatives --config java
sudo update-alternatives --config javac
Answer from GAD3R on Stack Overflow
🌐
Techoral
techoral.com › blog › java › install-openjdk-15-debian.html
Open Jdk - How To Install OpenJDK Java 15 On Debian Real Quick
March 22, 2025 - $ sudo apt-get install openjdk-15-jreThe openjdk-15-jre package contains just the Java Runtime Environment. If you want to develop Java programs then please install the openjdk-15-jdk package.
Discussions

How to install latest OpenJDK on Debian? - Unix & Linux Stack Exchange
I have Debian 10 and openjdk-11-jdk installed from the Debian repository. I have to run a program that was compiled with Java runtime version 58 so I need to update it. I downloaded the .tar.gz of OpenJDK 15 available at java.net. I extracted the file in /usr/local/bin since it was listed in ... More on unix.stackexchange.com
🌐 unix.stackexchange.com
February 17, 2021
Will Minecraft Java edition be reprogrammed for Java 11?

Minecraft comes with a private JRE on Windows, which means its security problems should typically not be as much of a concern for the operating system. Of course having to use a system JRE is a problem on other operating systems. As someone who considers switching to Linux myself before Win7 support runs out, I sure hope Mojang will address that problem soon, and not just Soon™.

More on reddit.com
🌐 r/Minecraft
3
3
April 29, 2019
Trying to run 1.12.2 mods on a mac and it wants me to install a JDK to use Forge. Which version of Java should I be using?

Do you need an oracle account to access https://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html ? It doesn't seem to ask for one for me.

More on reddit.com
🌐 r/feedthebeast
8
0
January 9, 2019
How do I install shaders? 1.15.2
The shaders you want to use entirely depend on what you like and what your PC can handle. For a guide, install OptiFine from https://optifine.net/home for 1.15, and look online for a shader. Download one you like, and put the ZIP folder in %appdata%/.minecraft/shaderpacks. In Minecraft, go to Video Settings and there should be a button labeled Shaders. Click on that and select your pack. More on reddit.com
🌐 r/Minecraft
13
8
February 23, 2020
🌐
Linux Uprising
linuxuprising.com › 2020 › 09 › how-to-install-oracle-java-15-on-ubuntu.html
How To Install Oracle Java 15 On Ubuntu, Debian Or Linux Mint Using APT PPA Repository - Linux Uprising Blog
April 14, 2021 - Ubuntu, Linux Mint, Pop!_OS and ... (Oracle JDK 15) for x64 / aarch64 only: sudo add-apt-repository ppa:linuxuprising/java sudo apt update sudo apt install oracle-java15-installer Debian and other Linux distributions based ...
🌐
Pi My Life Up
pimylifeup.com › home › installing newer versions of java on debian systems
Installing Newer Versions of Java on Debian Systems - Pi My Life Up
January 21, 2026 - In this quick guide, we will show you how to easily install the latest versions of Java on to your Debian based system.
🌐
Debian
packages.debian.org › sid › openjdk-15-jdk
Debian -- Error
See our contact page to get in touch · Content Copyright © 1997 - 2025 SPI Inc.; See license terms. Debian is a trademark of SPI Inc. Learn more about this site
🌐
Debian
wiki.debian.org › Java
Java - Debian Wiki
Each of them have a development environment (JDK) and a runtime (known as JRE, or Java Virtual Machines JVM). Here's a list of Java environment. Just run aptitude search "?provides(java-runtime)" on your system to list available packages). The default JRE/JDK installed in Debian isn't the same ...
🌐
Oracle
docs.oracle.com › en › java › javase › 15 › install › installation-jdk-linux-platforms.html
3 Installation of the JDK on Linux Platforms - Java
$ rpm -Uvh jdk-15.interim.update.patch_linux-x64_bin.rpm ... Delete the .rpm file if you want to save disk space. Exit the root shell. It is not required to reboot. The JDK installation is integrated with the alternatives framework. After installation, the alternatives framework is updated to reflect the binaries from the recently installed JDK. Java commands such as java, javac, javadoc, and javap can be called from the command line.
Find elsewhere
🌐
Tutorial for Linux
tutorialforlinux.com › step-by-step – oracle jdk 15 installation in debian buster
Step-by-step - Oracle JDK 15 Installation in Debian Buster • tutorialforlinux.com
March 22, 2021 - GNU/Linux Debian Buster Oracle JDK 15 Installation Guide Hi! The Tutorial shows you Step-by-Step How to Download and Install Oracle JDK 15 in Debian Buster 10.x 64-bit GNU/Linux. And Java SE 15 for Debian Buster is a Development Environment for Building Applications, and Components Using the Java Programming Language.
🌐
TecAdmin
tecadmin.net › how-to-install-java-on-debian-10-buster
How To Install Java on Debian 10 (Buster) – TecAdmin
April 26, 2025 - In this descibed you ot how to install Java (OpenJDK) 14, 11 and 8 on a Debian system.
🌐
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 - In this guide, you will install different versions of the Java Runtime Environment (JRE) and the Java Developer Kit (JDK) using Apt. You’ll install OpenJDK a…
🌐
Tutorials24x7
java.tutorials24x7.com › blog › how-to-install-java-15-on-ubuntu-20-04-lts
How To Install Java 15 On Ubuntu 20.04 LTS | Tutorials24x7
November 19, 2020 - Open the browser and search for Download JDK 15 or click the link to download from the Oracle website. It will show the JDK download page as shown in Fig 1. ... Click the download link as highlighted in Fig 1. It will ask to accept the License ...
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.

🌐
Myvestacp
forum.myvestacp.com › board index › knowledge base › linux tutorials › linux services
How to install Java on Debian - myVesta
apt install -y default-jre default-jdk With these two commands, you have successfully installed Java on your Debian system along with myVesta CP.
🌐
Debian
debian.club › installing java
Installing Java | Debian.Club
4 weeks ago - You can install them by specifying the version number in the package name. You can first search the software repository to see which OpenJDK versions are available. ... If you have multiple Java versions installed on your system, you can use ...
🌐
Linux Hint
linuxhint.com › install_jdk_debian_10
Installing JDK on Debian 10 – Linux Hint
August 25, 2023 - As you can see, the path is /usr/lib/jvm/jdk-12.0.2/bin/javac. So, the JAVA HOME directory is /usr/lib/jvm/jdk-12.0.2 (Remember that). The Oracle JDK DEB package does not add the JDK binaries to the PATH. So, we have to manually update the PATH environment variable of Debian 10.
🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-install-java-with-apt-get-on-debian-8
How To Install Java with Apt-Get on Debian 8 | DigitalOcean
June 28, 2017 - This tutorial will guide you through the process of installing and managing different versions of Java using apt-get on Debian 8. The programming language Ja…
🌐
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.
🌐
ComputingForGeeks
computingforgeeks.com › home › install java 25 (jdk 25) on debian 13 / debian 12
Install Java 25 (JDK 25) on Debian 13 / Debian 12 [Tested]
March 25, 2026 - This guide covers three installation methods: OpenJDK from Debian repos, Oracle JDK from Oracle’s .deb package, and Eclipse Temurin from the Adoptium repository. It also walks through switching between multiple Java versions, setting JAVA_HOME correctly, testing JDK 25 features like compact source files and module imports, and configuring garbage collectors.
🌐
HowtoForge
howtoforge.com › home › how to install java (jdk and jre) on debian 10
How to Install Java (JDK and JRE) on Debian 10
Run the 'apt info' command below to get details about the Java package. ... Now you will get the details package as below. Next, install the 'default-jdk' package using the apt command below.
🌐
Greenwebpage
greenwebpage.com › home › blog › how to install java on debian 12: using apt and deb
How to Install Java on Debian 12: Using Apt and Deb
May 10, 2025 - This tutorial walks you through steps to install Java on Debian 12 using both apt package manager and .deb.