Digital Communication


Digital Communication

Install Java Ubuntu: step by step tutorial


The fact that one can install Java on Windows 11 is common knowledge, but adding it to a machine running Linux is just as easy. To install Java on Ubuntu, you only need one thing: the command sudo apt install default-jre.

Web hosting with personal advisor!

Powerful, flexible and high-performance web hosting with mailbox, personal advisor and domain included 1time year !

SSL certificate
24/7 Support

Install Java on Ubuntu: Quick Guide

  1. Launch terminal
  2. Update package index
  3. Check if Java is already installed on Ubuntu
  4. Make a query of the current version and confirm it via sudo apt install default-jre
  5. Make sure the installation is successful.

What should you consider if you want to install Java on Ubuntu?

Although many programs use or require Java under Linux, the corresponding packages still often have to be installed manually. To install Java on Ubuntu, a few prerequisites must be met. First, you should know your current Ubuntu version, so you can download the correct packages. You will also need an Ubuntu server with a non-root sudo user. Just install Open JDK.

Download Java on Ubuntu

Depending on your needs, you can choose from different versions: a Standard Edition (SE), Enterprise Edition (EE) and Micro Edition (ME). We recommend that you go to the official site to install Java on Ubuntu. New versions of Java are released approximately every six months. Open JDK versions 8, 11 and 17 currently have wide support and are recommended for installing Java on Ubuntu. Open JDK is an open-source variant of the Java Runtime Environment (JRE) and the Java Development Kit (JDK).

Java on Ubuntu: installation

Installation is simple and requires only a few Java commands:

  1. Launch the terminal with the key combination [Ctrl] + [Alt] + [T].
  2. Update the package index to install Java on Ubuntu to its latest version using the command:
  1. Check if Java is already installed on Ubuntu. To do this, enter the following:
  1. If no version has been installed, the following is displayed:
Command 'java' not found, but can be installed with:
apt install default-jre
apt install [première version actuellement disponible]
apt install [deuxième version actuellement disponible]
  1. To install Java on Ubuntu, enter the following command:
$ sudo apt install default-jre
  1. You will be asked if you wish to continue. Confirm with “Y” or “N” and press the enter key. This installs the Java Runtime Environment.
  2. Finally, check if Java is already installed on Ubuntu using the command again:

If the installation was successful, the terminal will display the version you have chosen and you can start using Java right away.

Install specific versions

While installing using the default option is recommended because it installs the latest version, you can select specific versions. This may be necessary if you are running programs or applications that require older versions or Java operators.

Install Java 8 on Ubuntu

Java 8 is an older version but is still compatible with many systems. To install Open JDK 8, enter the following command:

$ sudo apt install openjdk-8-jre

Check if the installation was successful by entering the following command:

If the installation of Java 8 on Ubuntu was successful, the following should be displayed:

openjdk version "1.8.0_162"
OpenJDK Runtime Environment (build 1.8.0_162-8u162-b12-1-b12)
OpenJDK 64-Bit Server VM (build 25.162-b12, mixed mode)

Install Java 11 on Ubuntu

You can also install Java 11 on Ubuntu using the following commands:

$ sudo apt install openjdk-11-jre

Check if the installation was successful using the command:

Install Oracle Java on Ubuntu

To install Oracle Java on Ubuntu, be sure to read the license agreement, which contains restrictions on commercial use. The installation works as follows (we are using Oracle Java 11 for the example):

  1. Before creating a new repository, enter the following command:
$ sudo apt install software-properties-common
$ sudo add-apt-repository ppa:linuxuprising/java
  1. You will receive a message with your deposit information. Confirm this by hitting Enter.
  2. Update the list of packages using the following command:
  1. Now install Java 11 on Ubuntu:
$ sudo apt install oracle-java11-installer
  1. Before installation, you will be prompted to accept the license agreement. Accept to continue
  2. Check if the installation was successful:
  1. The result shows you which version you are using.

Set standard version

There are situations where you may need to install multiple versions of Java. For example, when certain programs are only compatible with a certain version. To find out which version of Java you have installed on your Ubuntu, use the command:

You can set a version to use as default using the command line. Use the update-alternatives command to do this:

$ sudo update-alternatives --config java

A list of all installed versions will be displayed. Under the phrase ” There are [nombre] choices for the alternative java (providing /usr/bin/java.) you will find which versions it is (under “Path”), the priority (“Priority”), the status and a selection number (“Selection”). Confirm your settings by hitting Enter. To set a default version, enter the selection number and click confirm.

After Installing Java on Ubuntu: Set Environment Variables

Since some programs that work using Java rely on the JAVA_HOME environment variable to determine the installation location, it makes sense to set it in advance. To do this, use the “update-alternatives” command:

$ sudo update-alternatives --config java
  1. All installation routes are displayed under “Path”. Select the route of the Java version you need and copy it.
  2. Open the /etc/environment using the text editor or the following command in nano:
$ sudo nano /etc/environment
  1. Paste the copied route at the end of the file:
JAVA_HOME="[preferred path]"
  1. If a route is already set, overwrite it.
  2. To apply the changes, use:
$ source /etc/environment
  1. Check the set route:

The settings apply to all users.

Télécharger notre livre blanc

Comment construire une stratégie de marketing digital ?

Le guide indispensable pour promouvoir votre marque en ligne

En savoir plus

Souhaitez vous Booster votre Business?

écrivez-nous et restez en contact