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 OverflowHow to install latest OpenJDK on Debian? - Unix & Linux Stack Exchange
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.comTrying 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.comHow do I install shaders? 1.15.2
Videos
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.