EDIT: I've ended up installing Microsoft's OpenJDK 21. Had a nice instructions to setup and i didnt need to mess up my debian repositories to get the thing (only add MS one). Sorry die-hard Linux fans
I'm trying to install the JRE of Java 21 in my Debian 12 headless machine, for Minecraft server purposes.
Unfortunately i saw that the packages of 21 aren't available in stable repositories, only on sid (unstable). I don't want to add the whole sid repository to avoid instability and since the only package i want is this one.
So, is there any way to install Java 21 using either apt or a .deb file - without resorting to unpack a .tar.gz? Should i download the .deb on the website and try to install it via gdebi-core? I read that this isn't an advised thing to do due to dependencies and such...
How can I install Java 8 on Debian 12 (bookworm)? - Unix & Linux Stack Exchange
Comment installer Java 8 sur Debian 12 ?
Java installation Debian 12
How can i install Java 21 on Debian 12 without resorting to sid?
Videos
Thorsten Glaser, the current maintainer of OpenJDK 8 in Debian, provides a repository which includes OpenJDK 8, built using the Debian OpenJDK 8 package (see also Debian bug #989736).
To install it on Debian 12, download the appropriate repository configuration file:
wget http://www.mirbsd.org/~tg/Debs/sources.txt/wtf-bookworm.sources
sudo mkdir -p /etc/apt/sources.list.d
sudo mv wtf-bookworm.sources /etc/apt/sources.list.d/
sudo apt update
You’ll then see openjdk-8-jdk, openjdk-8-jre, etc. available for installation as usual:
sudo apt install openjdk-8-jdk
I am using the distrubution offered by adoptium, called temurin-8-jdk
mkdir -p /etc/apt/keyrings
wget -O - https://packages.adoptium.net/artifactory/api/gpg/key/public | tee /etc/apt/keyrings/adoptium.asc
echo "deb [signed-by=/etc/apt/keyrings/adoptium.asc] https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | tee /etc/apt/sources.list.d/adoptium.list
apt update
apt install temurin-8-jdk
Optional to switch from an old repository
update-alternatives --config java # choose new java
update-alternatives --config javac # choose new javac