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
(Alternatively, you may opt to use a specific Java version, using for example the openjdk-11-jre package; as updates are released for that version of the Java Virtual Machine, that packages will be updated, allowing you to stick to the latest and greatest update of one specific version of the Java language.) ... 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.
Discussions

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
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
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
How do I install Java JRE on Linux?
Do you need to install Oracle's Java? Cuz if you don't need you can just open a terminal and type sudo apt install default-jre -y and it's ready to use (if you're on debian-based distros) More on reddit.com
🌐 r/linuxquestions
15
7
February 16, 2021
🌐
Oracle
java.com › en › download › help › linux_x64_install.html
Linux 64-bit installation instructions for Java
Java for Ubuntu Java for Fedora · Follow these steps to download and install Java for Linux. ... This procedure installs the Java Runtime Environment (JRE) for 64-bit Linux, using an archive binary file (.tar.gz). Go to http://java.com and click on the Download ...
🌐
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.
🌐
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
Here's the easiest way to install Java on Ubuntu with apt. Follow these steps and you'll get the JDK installed in no time, and be ready to use your Java on Ubuntu setup right away.
🌐
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...
Find elsewhere
🌐
PhoenixNAP
phoenixnap.com › home › kb › sysadmin › how to install java on ubuntu
How to Install Java on Ubuntu
February 20, 2025 - Install one or several Java packages on your system, or choose a specific version by specifying the version number. By default, Ubuntu includes OpenJDK as the Java Development Kit (JDK) and Java Runtime Environment (JRE).
🌐
GeeksforGeeks
geeksforgeeks.org › techtips › how-to-install-java-in-ubuntu
How to install Java in Ubuntu - GeeksforGeeks
February 14, 2026 - Default JDK and JRE packages are available in Ubuntu repositories. Specific Oracle Java versions can be installed when required. Installation is performed using terminal commands. Java version can be verified after installation. To Install Java on Ubuntu, We're going to see the following 2 methods:
🌐
Hostinger
hostinger.com › home › tutorials › how to install java on ubuntu
How to Install Java on Ubuntu
January 13, 2026 - Check this article to learn how to install Java on Ubuntu: 1. Update the package index 2. Install JRE 3. Install a specific Java version and more.
🌐
CyberPanel
cyberpanel.net › blog › install-java-on-linux-ubuntu
Install Java on Linux Ubuntu Easily: Your Ultimate Guide
April 7, 2025 - Is it possible to install multiple Java versions on Ubuntu? Yes, and you can select which one to use via sudo update-alternatives –config java. ... You can run readlink -f $(which java) to get the path of your Java binary. Finally, we have learned to install Java on Linux Ubuntu.
🌐
IONOS
ionos.com › digital guide › server › configuration › install java on ubuntu
How to install Java on Ubuntu step by step - IONOS
October 31, 2022 - It’s well known that you can install Java on Windows 11 but adding it to a machine running Linux is just as easy. To install Java on Ubuntu all you need is the command sudo apt install default-jre.
🌐
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.
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

🌐
freeCodeCamp
freecodecamp.org › news › how-to-install-java-in-ubuntu-jdk-linux-tutorial
How to Install Java in Ubuntu – JDK Linux Tutorial
June 28, 2022 - Once a new Java version is available, it should be listed via sdk list java. But, you can also use sdk upgrade java to ask sdkman to check for updates. ... $ sdk uninstall java 17.0.3-tem $ sdk install java 17.0.2-tem $ sdk install java 11.0.12-tem $ sdk upgrade java Available defaults: java (local: 18.0.1-tem, 11.0.12-tem, 17.0.2-tem; default: 17.0.3-tem) Use prescribed default version(s)?
🌐
It's FOSS
itsfoss.com › install-java-ubuntu
How to Install Java on Ubuntu and Linux Mint [Properly]
August 1, 2024 - This will install the latest JDK available from Ubuntu. But if you want to install a specific version, you can use openjdk-21-jdk, openjdk-17-jdk or openjdk-11-jdk instead of default-jdk in the above command. Search for available Java versions on your system: ... This will have a huge output with various packages that contain the term -jdk in their name. Look for packages like openjdk-XX-jdk and install them. Let's say you want to install openjdk-11-jdk which is available for your Linux system.
🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-install-java-with-apt-on-ubuntu-20-04
How To Install Java with Apt on Ubuntu | DigitalOcean
February 5, 2026 - Start by visiting Oracle’s official Java SE download page and selecting the required JDK version for Linux. Download the .tar.gz archive that matches your system architecture. Once the download is complete, transfer the archive to your Ubuntu system if you downloaded it on another machine.
🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-install-java-with-apt-on-ubuntu-18-04
How To Install Java with Apt on Ubuntu 18.04 | DigitalOcean
October 12, 2021 - In this guide, you will install various versions of the Java Runtime Environment (JRE) and the Java Developer Kit (JDK) using apt . You’ll install OpenJDK …
🌐
Contabo
contabo.com › home › how to install java on ubuntu 18.04, 20.04 & 22.04 using apt-get
How To Install Java on Ubuntu 18.04, 20.04 & 22.04 using Apt-Get
August 11, 2023 - In this comprehensive step-by-step guide you will learn how to install different versions of Java on your Ubuntu server using Apt-Get.
🌐
LinuxConfig
linuxconfig.org › home › how to install and switch java versions on ubuntu linux
How to Install and Switch Java Versions on Ubuntu Linux
September 21, 2025 - To update Java, use the command ‘sudo apt-get update’ followed by ‘apt-get install java-package’, where ‘java-package’ is the package name of the Java version you wish to install.