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 ExchangeVideos
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)
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.
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
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:
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)
Choose stretch repository
Scroll to the Download openjdk-8-jdk section and choose your architecture. For example amd64
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:
Install software source manager
apt-get update apt-get install software-properties-commonAdd mirror with openjdk-8-jdk
apt-add-repository 'deb http://security.debian.org/debian-security stretch/updates main' apt-get updateInstall 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
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