For Ubuntu 22.04, you should be able to simply:
sudo apt install openjdk-21-jdk
It's in the Universe repository, so be sure you have that enabled.
It wasn't available yet when you asked the question, but it is now.
If you add a PPA or other non-Ubuntu version of OpenJDK, remember that it's likely to be incompatible with the (supported Ubuntu repository) Ubuntu package. So keep track of what you install; you might need to remove all of it.
Answer from user535733 on askubuntu.comHow can i install Java 21 on Debian 12 without resorting to sid?
where can i download java 21?
How to install Java?
Installing Java on Arch
Videos
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...