Install the Java Runtime Environment

Key Value
Summary Installation of Java Runtime Environment (JRE) on Ubuntu
Categories desktop
Difficulty 1
Author Aden Padilla


Duration: 1:00

The Java Runtime Environment (JRE) is required to run Java programs. Nowadays there are many JRE packages available from a variety of projects and companies, but the two most popular on Ubuntu are OpenJDK and Oracle HotSpot. Using one package over the other should not create any functional difference in most applications; however, some prefer OpenJDK over Oracle HotSpot as the former does not contain closed-source components, has a much clearer licensing and support policy, and is maintained as part of the Ubuntu archive, with easier installation and upgrades.

In this guide, we’ll be going through the installation of both JRE packages. Of course, you generally only need to pick the one that best suits your needs and preferences.

What you’ll learn

  • How to install OpenJDK JRE
  • How to install Oracle HotSpot JRE

What you’ll need

  • A machine running Ubuntu

That’s all you need. If you have that, let’s proceed to the next step!

Installing OpenJDK JRE

Duration: 2:00

With new versions of Java released every 6 months, there are multiple versions available for use. Nowadays, Java 11 is the current Long Term Support (LTS) version, but Java 8 is still widely used. Moreover, the non LTS versions of Java are bringing a steady stream of innovation into the language, and also see some adoption.

Ubuntu offers the default-jre package, which is regularly updated to ship the latest version of the current OpenJDK JRE in Long Term Support (LTS). The default-jre is an excellent choice for most situations, thanks to the outstanding track of backwards compatibility of the Java Virtual Machine.

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

To install the OpenJDK JRE, we run:

sudo apt install default-jre

We can check if OpenJDK JRE was properly installed by running:

java -version

It should output the following:

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.

Installing Oracle HotSpot JRE

Duration: 5:00

Downloading the Oracle HotSpot JRE binaries

Download JRE binaries in .tar.gz (tarball) by heading over to their website. An Oracle account is needed to download the Oracle HotSpot JRE.

Oracle does not currently offer JRE packages for Java 11 or above from their website so, for this tutorial, we will use the Oracle HotSpot JRE version to be 8u291 (Java 8, update 291).


Create a directory to install JRE in with:

sudo mkdir /usr/local/java

Move the JRE binaries into the directory:

sudo mv jre-8u291-linux-x64.tar.gz /usr/local/java

Go into the install directory:

cd /usr/local/java

Unpack the tarball:

sudo tar zxvf jre-8u291-linux-x64.tar.gz

Post-installation steps

To save space, delete the tarball by running:

sudo rm jre-8u291-linux-x64.tar.gz

Let the system know where JRE is installed:

sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jre1.8.0_291/bin/java" 1

After that’s done, check the installation by running:

java -version

It should output the following:

java version "1.8.0_291"
Java(TM) SE Runtime Environment (build 1.8.0_291-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.291-b10, mixed mode)

Need further assistance?

1 Like

The java version mentioned on this install is dated.
I just type java --version in my terminal and it says not found, but can be installed with:
sudo apt install default-jre
…8, 13 & 14
Is there a problem saying on this page to install default-jre? That way maybe it will never go out of date again?

Thanks @wizardave, you are completely right about it! On it :wink:

sudo mv jre-8u291-linux-x64.tar.gz /usr/local/java does not work. can anyone help?

It might be helpful to add that some software expects a $JAVA_HOME , and also that the open JDK runtime does not seem to fulfil compatibility for latest Java software.

late to you but you need to change directories
command cd

Please add that you need to change direnctories to Downloads to move the file. I am new to linux and this threw me for a loop