Because Java 25 LTS is coming soon (September 2025) and I've not even yet installed Java JDK 21 LTS (September 2023), I've attempted to do so with a sudo apt install openjdk-21-jdk
on my Debian 12. But it failed with a package not found
message.
Its package isn't available yet on Debian 12: openjdk-21 (except on sid
).
I'm considering downloading it from https://jdk.java.net/archive/ as a tar.gz
of 21.0.2 (build 21.0.2+13)
version (at the cost of forgetting apt
commands to handle Java, and writing on my agenda to check manually for updates there)
But I'm fearing this:
Won't the .deb
included in this .tar.gz
break my system if I attempt to install it,
if the dedicated openjdk-21-jdk
package for Debian 12 cannot be created for years?
2 Answers 2
Installing an archive from java.jdk.net isn’t safe, but not because of packaging issues. The Java 21 archives there don’t receive updates, and 21.0.2 is affected by a number of issues which have been fixed in later releases.
Since Debian doesn’t provide a package for Debian 12 (and probably won’t, ever — you’ll get it in 13 but I doubt it will be backported), you’ll need to download it elsewhere. A good option is to use one of the verified releases available from Adoptium.
As long as you extract the tarball in a location under /opt
, /usr/local
, or even your home directory, it won’t break your system. You should resist the temptation to make it available using update-alternatives
, and instead rely on setting JAVA_HOME
and PATH
appropriately where necessary.
Stéphane Chazelas’ comments regarding the target environment are worth bearing in mind — if your goal is to produce applications for use on Debian 12, you might be better off sticking with Java 17. The upgrade to Java 21 will be much easier on Debian 13, released in August 2025. Otherwise you’ll need to manage the runtime environment wherever you need to deploy the applications you build, or use something like Quarkus and build a native application.
-
Oh, if Debian 13 comes this summer, it's worth waiting it, yes. But you gave me the answer I was searching for: it's not recommended to install Java 21 yet on Debian 12 as a natural upgrade for Java, without being cautious.Marc Le Bihan– Marc Le Bihan2025年04月20日 19:08:03 +00:00Commented Apr 20 at 19:08
If the tarball contains a set of files, keep them out of the system standard directories and put them under either /opt
or /usr/local
. Easier to delete manually when no longer required.
If the tarball contains a deb
then provided you know what you're installing, the package manager will handle dependencies and you can remove the package manually (apt remove {package}
) when no longer required
sid