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.com
🌐
Red Hat
docs.redhat.com › en › documentation › red_hat_build_of_openjdk › 21 › html-single › installing_and_using_red_hat_build_of_openjdk_21_on_rhel › index
Installing and using Red Hat build of OpenJDK 21 on RHEL | Red Hat build of OpenJDK | 21 | Red Hat Documentation
Select the latest version of Red Hat build of OpenJDK 21 from the Version drop-down list, and then download the JRE archive for Linux to your local system. Extract the contents of the archive to a directory of your choice. ... When installed using this method, Java will only be available for ...
🌐
TheServerSide
theserverside.com › blog › Coffee-Talk-Java-News-Stories-and-Opinions › How-do-I-install-Java-on-Ubuntu
How to install Java 21 on Ubuntu
Install the JDK with the following command: sudo apt install default-jre Setting up default-jdk-headless (2:1.21) ... Setting up openjdk-21-jdk:amd64 (21.0.5+11-1ubuntu~24.04.1) ...
Discussions

How can i install Java 21 on Debian 12 without resorting to sid?
I recommend temurin jdk and they have their own packages. Zulu is also good. https://adoptium.net/installation/linux/ https://docs.azul.com/core/install/debian More on reddit.com
🌐 r/linux4noobs
26
25
July 15, 2024
where can i download java 21?
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/javahelp
16
3
June 23, 2024
How to install Java?
I think the first command will install the LTS version, which is currently 11. This has always been confusing on Debian distros. Are you just running java? Or are you looking to build new java code? Install the jdk if you want to build, not the jre. More on reddit.com
🌐 r/pop_os
4
5
February 25, 2020
Installing Java on Arch
https://wiki.archlinux.org/title/Java Should tell you basically anything you need. Also, you can use the community editions of intellij, I think they are available on the AUR. More on reddit.com
🌐 r/archlinux
8
4
July 31, 2021
🌐
RoseHosting
rosehosting.com › home › how to install java 21 on ubuntu 24.04
How to Install Java 21 on Ubuntu 24.04 | RoseHosting
May 8, 2024 - Once downloaded, you can install the package with the command below: ... root@host:~# java -version openjdk version "21.0.2" 2024-01-16 OpenJDK Runtime Environment (build 21.0.2+13-Ubuntu-2) OpenJDK 64-Bit Server VM (build 21.0.2+13-Ubuntu-2, ...
🌐
Oracle
docs.oracle.com › en › java › javase › 21 › install › installation-jdk-linux-platforms.html
3 Installation of the JDK on Linux Platforms
July 15, 2025 - Change the directory to the location where you want to install the JDK, then move the .tar.gz archive file to the current directory. Unpack the tarball and install the downloaded JDK: ... The Java Development Kit files are installed in a directory named jdk-21.interim.update.patch.
🌐
Reddit
reddit.com › r/linux4noobs › how can i install java 21 on debian 12 without resorting to sid?
r/linux4noobs on Reddit: How can i install Java 21 on Debian 12 without resorting to sid?
July 15, 2024 -

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...

🌐
ComputingForGeeks
computingforgeeks.com › home › install java 21 (openjdk 21) on ubuntu 24.04|22.04|20.04
Install Java 21 (OpenJDK 21) on Ubuntu [Guide]
March 21, 2026 - Step-by-step guide to java 21 (OpenJDK 21) on Ubuntu 24.04|22.04|20.04. Includes commands, verification, and troubleshooting.
Find elsewhere
🌐
TecMint
tecmint.com › home › debian › how to install java jdk 21 on debian 12
How to Install Java 21 (JDK) on Debian 12
June 27, 2024 - The easiest way to install Java 21 on Debian 12 is by using the apt package manager as a regular user with sudo privileges and updating the system packages as shown. ... If you want to check if Java is installed, run the command.
🌐
LinuxVox
linuxvox.com › blog › install-java-21-linux
Installing Java 21 on Linux: A Comprehensive Guide — linuxvox.com
For example, if using Red Hat, you may need to subscribe to the appropriate channels. For CentOS, you can use the dnf package manager: ... Download the Java 21 JDK from the official Oracle or OpenJDK website.
🌐
UbuntuHandbook
ubuntuhandbook.org › home › howtos › install oracle java jdk 21, 25, or 26 in ubuntu 24.04 | 22.04 | 20.04
Install Oracle Java JDK 21, 25, or 26 in Ubuntu 24.04 | 22.04 | 20.04 | UbuntuHandbook
sudo apt install ~/Downloads/jdk-21_linux-x64_bin.deb · Here replace 21 in command if you downloaded JDK 25 or 26. Or, just drag and drop the .deb package from your downloads folder into terminal to auto-insert path to that file. The .deb package include a post-install script that automatically ...
🌐
Javadownload
javadownload.org › blog › java-21-install-linux
How to Install Java 21 LTS on Linux: A Complete Step-by-Step Guide — javadownload.org
May 11, 2026 - # For Fedora sudo dnf install -y java-21-openjdk-devel · For RHEL 9/Rocky Linux 9, ensure the appstream repository is enabled (usually default):
🌐
javathinking
javathinking.com › blog › jdk-21-install-linux
Installing JDK 21 on Linux: A Comprehensive Guide — javathinking.com
sudo update-alternatives --config java # Select the JDK 21 path from the list sudo update-alternatives --config javac # Repeat for javac · Cause: Incorrect file permissions on the JDK directory. Fix: Set ownership to root (system-wide) or your user (user-specific): sudo chown -R root:root /usr/lib/jvm/jdk-21.0.1+12 # System-wide # OR chown -R $USER:$USER ~/jdk21 # User-specific · Cause: SDKMAN! initialization not loaded in the shell. ... By following this guide, you’ll have JDK 21 installed and configured on your Linux system, ready for development or production use.
🌐
Java With Us
javawithus.com › home › faq › how to install java on linux (all distros)
How to Install Java on Linux (All Distros) | Java With Us
April 21, 2026 - Linux has the easiest Java install path of any OS — every major distribution ships OpenJDK in its standard package manager. One command gets you a working JDK. sudo apt update sudo apt install openjdk-21-jdk java -version
🌐
LinuxVox
linuxvox.com › blog › install-java-21-ubuntu
Installing Java 21 on Ubuntu: A Comprehensive Guide — linuxvox.com
# Add the Adoptium GPG key wget ... apt install temurin - 21 - jdk · Download Java 21 Visit the Adoptium website and download the appropriate Java 21 JDK binary for Linux (usually in .tar.gz format)....
🌐
Red Hat
docs.redhat.com › en › documentation › red_hat_build_of_openjdk › 21 › html › installing_and_using_red_hat_build_of_openjdk_21_on_rhel › installing-openjdk-on-rhel_openjdk
Chapter 2. Installing Red Hat build of OpenJDK 21 on Red Hat Enterprise Linux | Installing and using Red Hat build of OpenJDK 21 on RHEL | Red Hat build of OpenJDK | 21 | Red Hat Documentation
Select the latest version of Red Hat build of OpenJDK 21 from the Version drop-down list, and then download the JRE archive for Linux to your local system. Extract the contents of the archive to a directory of your choice. ... When installed using this method, Java will only be available for ...
🌐
AWS
docs.aws.amazon.com › corretto › corretto 21 user guide › amazon corretto 21 guide for linux › amazon corretto 21 installation instructions for debian-based, rpm-based and alpine linux distributions
Amazon Corretto 21 Installation Instructions for Debian-Based, RPM-Based and Alpine Linux Distributions - Amazon Corretto 21
After the repository is added, you can install Corretto 21 by running this command: ... Download the Linux .rpm file from the Downloads page. Install the downloaded .rpm file using yum localinstall. For example install x86_64 rpm using the following command: sudo yum localinstall java-21-ama...
🌐
Linux Today
linuxtoday.com › home › blog
How to Install Java 21 on Debian 13 | Linux Today
June 26, 2025 - In this blog post, we will explain how to install Java 21 on Debian 13 OS in detail. Java is a high-level, object-oriented programming language with a syntax similar to C and C++.
🌐
PhoenixNAP
phoenixnap.com › home › kb › sysadmin › how to install java on ubuntu
How to Install Java on Ubuntu
February 20, 2025 - This process allows you to add a third-party repository to your system, which simplifies installation and provides automatic updates. Take the following steps: ... In some cases, like the example above, the dependencies come preinstalled on the system. ... Note: For newer versions of Java (such as Java 21), replace oracle-java17-installer with oracle-java21-installer, but note Java 21 is a non-LTS release.
🌐
Javadownload
javadownload.org › blog › java-21-install
How to Install Java 21 (LTS): A Complete Guide for Windows, macOS, and Linux — javadownload.org
May 11, 2026 - The easiest way to install Java 21 on Ubuntu or Debian is through the official repositories: ... Download the Linux .tar.gz from a provider like Oracle or Adoptium.