try using this command in the terminal:

sudo apt install default-jre

then you can try using:

java -version

to check version

Answer from neoMidori on askubuntu.com
๐ŸŒ
Ubuntu
ubuntu.com โ€บ tutorials โ€บ install-jre
Install the Java Runtime Environment | Ubuntu
openjdk version "11.0.11" 2021-04-20 OpenJDK Runtime Environment (build 11.0.11+9-Ubuntu-0ubuntu2) OpenJDK 64-Bit Server VM (build 11.0.11+9-Ubuntu-0ubuntu2, mixed mode) (Although the output may change in the future as new Java versions are promoted to LTS status, or the current LTS version receives updates.) And thatโ€™s it! In the next step weโ€™ll install Oracle HotSpot JRE.
๐ŸŒ
DigitalOcean
digitalocean.com โ€บ community โ€บ tutorials โ€บ how-to-install-java-with-apt-on-ubuntu-22-04
How to Install Java with Apt on Ubuntu (JRE & JDK) | DigitalOcean
February 2, 2026 - Learn how to install Java (JRE & JDK) on Ubuntu using apt. Step-by-step guide to setting up Java, verifying installation, and managing multiple versions.
Discussions

Trying to install Java now.
If you're trying to play singleplayer modded Minecraft or join servers (not hosting a server), I recommend using a launcher like Prism Launcher . It'll auto-detect your Java version(s) and help manage your mods. You can install different Java versions by installing openjdk--jre where is the Java version, such as 17 or 1.8 (referred to as 8). More on reddit.com
๐ŸŒ r/Ubuntu
8
8
August 12, 2024
Installing Java 7 on Ubuntu - Stack Overflow
Note: This question was asked before Oracle made the OpenJDK the free version of the Oracle JDK, and the historic answers reflect that. As of 2022 you should not use Java 7 unless you must for pro... More on stackoverflow.com
๐ŸŒ stackoverflow.com
java - How to install the JDK on Ubuntu Linux - Stack Overflow
Note: This is an old question and the answers reflect the world as it was then. Modern Ubuntu distributions have OpenJDK available which can be installed with sudo apt install default-jdk I am tr... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Noob question. How do I update to Java 22 via terminal?
wget https://download.oracle.com/java/25/latest/jdk-25_linux-x64_bin.deb sudo dpkg -i jdk-25_linux-x64_bin.deb With Java anything higher than what you need is usually fine. Java 22 is just the minimum. More on reddit.com
๐ŸŒ r/Ubuntu
7
4
October 12, 2025
๐ŸŒ
OVHcloud
us.ovhcloud.com โ€บ home โ€บ how to install java on ubuntu 22.04 ?
How to install Java on Ubuntu 22.04 ?
$ sudo apt-get update && apt-get -y install openjdk-17-jdk Hit:1 http://security.ubuntu.com/ubuntu jammy-security InRelease Hit:2 http://nova.clouds.archive.ubuntu.com/ubuntu jammy InRelease Hit:3 http://nova.clouds.archive.ubuntu.com/ubuntu jammy-updates InRelease Hit:4 http://nova.clouds...
๐ŸŒ
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
While Ubuntu does not come with Javaโ€™s JDK preinstalled, it does come prepackaged with the ability to easily install Java with the apt command.
๐ŸŒ
Oracle
java.com โ€บ en โ€บ download โ€บ help โ€บ linux_x64_install.html
Linux 64-bit installation instructions for Java
This procedure installs the Java Runtime Environment (JRE) for 64-bit Linux, using an archive binary file (.tar.gz).
Find elsewhere
Top answer
1 of 4
8

Before I start, please note that the JDK also contains the JRE within it.

Method 1:

To install the openJDK JDK and JRE 8 use (replace 8 with the version you want, such as 7 or 6):

sudo apt-get install openjdk-8-jdk

Method 2:

If you instead want to install the official Oracle JDK and JRE and definitely want to install through apt-get then do (you can replace the 8 with other versions such as 9, or 7):

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

Method 3:

Or if you want to install the official Oracle Java version manually:

  1. Go here and click the download button:

  2. Select the Accept License Agreement radio button (once you have read the license agreement).

  3. Select the file you want to download, if you are running on a 32-bit machine click jdk-[javaversion]-linux-i586.tar.gz ([javaversion] replaced with the Java version, such as 8u60), if 64-bit then jdk-[javaversion]-linux-x64.tar.gz.

  4. Launch Terminal (CTRL + ALT + T), then cd to the directory where you downloaded the file to (probably ~/Downloads), and run tar -xvf /path/to/file.tar.gz to unpack that archive into the directory the file is in, you may then move that unpacked archive into a desired location, such as the /opt directory (storing executable files in your home directory is a security risk).

  5. Once you have done the above you may delete the original .tar.gz file, and then open up your ~/.bashrc file in a desired file editor such as gedit or vim, I will be using vim in this example (install it with sudo apt-get install vim if it is not already installed). So run vim ~/.bashrc and then insert two new lines at the bottom of the file which read (that is with /path/to/unpacked/archive replaced with the path to the archive you just unpacked):

    JAVA_HOME=/path/to/unpacked/archive
    export PATH=$PATH:$JAVA_HOME/bin
    
  6. Either restart Terminal or run source ~/.bashrc to start using the new .bashrc file.

    Note: With this method you will have to carry on doing this every time there is a new Java version released which it will not notify you about.

2 of 4
1

Open terminal and type

sudo apt-get install openjdk-7-jre

This package contains the Java Runtime Environment

๐ŸŒ
Oracle
java.com โ€บ en โ€บ download โ€บ help โ€บ linux_install.html
How do I download and install 32-bit Java for Linux?
Java on RPM-based Linux Platforms This installs the Java Runtime Environment (JRE) for 32-bit RPM-based Linux platforms, such as Red Hat and SuSE, using an RPM binary file (.rpm) in the system location. You must be root to perform this installation. Download the package that best suits your needs.
๐ŸŒ
OneUptime
oneuptime.com โ€บ home โ€บ blog โ€บ how to install java (openjdk) on ubuntu
How to Install Java (OpenJDK) on Ubuntu
January 15, 2026 - # Install OpenJDK 21 (LTS, released September 2023) sudo apt install openjdk-21-jdk -y # Install OpenJDK 17 (previous LTS) sudo apt install openjdk-17-jdk -y # Install OpenJDK 11 (older LTS, still widely used) sudo apt install openjdk-11-jdk -y # Install OpenJDK 8 (legacy, for older applications) sudo apt install openjdk-8-jdk -y ยท JDK (Java Development Kit): Full development environment with compiler, debugger, and tools
๐ŸŒ
Reddit
reddit.com โ€บ r/ubuntu โ€บ noob question. how do i update to java 22 via terminal?
r/Ubuntu on Reddit: Noob question. How do I update to Java 22 via terminal?
October 12, 2025 -

SOLVED. Thanks!

Version Ubuntu 24.04.03 LTS, currently on Java 21, need 22 for my Minecraft server but sudo apt install openjdk-22-jdk gives error, unable to locate package. Just apt update just gives you version 21 as that's what seems to be on Ubuntu rn.

I suspect I need to download whatever .tar.gz for java, send it over via FTP, SSH back in and run it somehow but I haven't actually done that before and am not that technically savvy so hoping someone has a clearer tutorial then Google being like just reinstall Ubuntu so there's a GUI.

๐ŸŒ
BlueVPS
bluevps.com โ€บ blog โ€บ step-by-step guide: how to install java on ubuntu 22.04
Step-by-Step Guide: How to Install Java on Ubuntu 22.04 - Blog - BlueVPS
September 25, 2023 - Choose the suitable version of OpenJDK and install it using the apt repository. ... Now, press โ€˜yโ€™ and โ€˜Enterโ€™ to proceed with the installation. The above command will install the complete JDK platform of the OpenJDK 17 version.
๐ŸŒ
Oracle
oracle.com โ€บ java โ€บ technologies โ€บ downloads
Download the Latest Java LTS Free
Download the Java including the latest version 17 LTS on the Java SE Platform. These downloads can be used for any purpose, at no cost, under the Java SE binary code license.
๐ŸŒ
OpenJDK
openjdk.org โ€บ install
OpenJDK: Download and install
The openjdk-7-jre package contains just the Java Runtime Environment. If you want to develop Java programs then install the openjdk-7-jdk package.
๐ŸŒ
Ubuntu
documentation.ubuntu.com โ€บ ubuntu-for-developers โ€บ reference โ€บ availability โ€บ java
Available Java versions - Ubuntu for Developers
April 5, 2026 - This page lists Java versions available in Ubuntu releases, including CRaC and GraalVM. Ubuntu OpenJDK (deb) packages:,,, Ubuntu version, available Java versions, java-common version,,, 25.10 (Ques...
๐ŸŒ
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 - We can install Java Development Kit 21 with the following command: ... 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, mixed mode, sharing)
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ techtips โ€บ how-to-install-java-in-ubuntu
How to install Java in Ubuntu - GeeksforGeeks
February 14, 2026 - The installation can be completed directly from the terminal using simple commands. Default JDK and JRE packages are available in Ubuntu repositories. Specific Oracle Java versions can be installed when required.