You have a computer running Linux, whatever the version (Ubuntu, Mint…), it is therefore imperative to know how to update Java, more precisely JRE, the Java execution environment.
Steps
Method 1 of 3: Install Java on Linux without RPM

Step 1. Go to the Java for Linux page
The site is on this link. Several solutions are proposed to you there.

Step 2. Click on Linux
This is the second link in the list, so you will retrieve the Java installation file.
- If you want the 64-bit version, click on the link Linux x64 (third in the list).

Step 3. Note the name of the file
The latest version of Java is version 8, but you also need to get the update number ("update"), so you should have a file that contains 8u followed by the update number.
So if your file is called jre-8u151, it means you have version 8 update 151

Step 4. Open the command line
Depending on the version of Linux installed, this operation changes. Generally speaking, you can simply open a terminal window (command prompt) or do for example Control + Alt + T in Linux Ubuntu.

Step 5. Change the installation directory
In the console, type cd, press the space bar once, then type the path, for example / usr / java /, and finally, validate with the Enter key.

Step 6. Enter the install command
Type tar zxvf, press the space bar once, then type the full name of the file. This name will depend on the day you downloaded your file.
-
So, in January 2018, you have to type:
tar zxvf jre-8u151-linux-i586.tar.

Step 7. Press the Enter key
Java is then on your computer and its files are in a folder named jre1.8.0_ [maj], [maj] being the update number (for example, 151).
Method 2 of 3: Install Java on Linux with RPM

Step 1. Go to the Java for Linux page
The site is on this link. Several solutions are available to you.

Step 2. Click Linux RPM
This is the first link on the list. By clicking on it, you will retrieve the Java RPM installation file.
- If you want the 64-bit version, click on the link Linux x64 RPM (fourth in the list).

Step 3. Note the name of the file
The latest version of Java is version 8, but you also need to get the update number ("update"), so you should have a file that contains 8u followed by the update number.
So if your file is called jre-8u151, it means you have version 8 update 151

Step 4. Open the command line
Depending on the version of Linux installed, this operation changes. Generally speaking, you can simply open a terminal window (command prompt) or do for example Control + Alt + T in Linux Ubuntu.

Step 5. Enter the root command
Type sudo su, then validate with the Enter key. You will then have to enter your user password.

Step 6. Enter your account password
Type it in the terminal, then validate with the Enter key. To be able to install Java, you must have administrator rights (root).
If you do not have root access with your account, you will need to enter the password of an account that has administrator privileges

Step 7. Change the installation directory
In the console, type cd, press the space bar once, then type the path, for example / usr / java /, and finally, validate with the Enter key.

Step 8. Enter the install command
Type rpm -ivh, press the space bar once, type the full name of the file, then validate with the Enter key. Java is then installed on your computer.
-
The name of the file will depend on the day you downloaded your file. So, in January 2018, you have to type:
rpm -ivh jre-8u151-linux-i586.rpm. Confirm with the Enter key.
Step 9. Update the installed Java
Type:
rpm -Uvh jre-8u73-linux-i586.rpm, then validate with the Enter key. The system will check for updates to Java packages and, if available, install them.
Method 3 of 3: Install Java on Linux Ubuntu (OpenJDK)

Step 1. Open the command line
On your keyboard, do the following combination:
Control + Alt + T, otherwise click on the black square on the left of the screen that contains a white "> _".

Step 2. Enter the update command
Type:
sudo apt-get install, then validate with the Enter key. So you can be sure you have the latest Java packages.

Step 3. Optionally enter your user password
If asked, type it, then validate with the Enter key.

Step 4. However, verify that Java is not already installed
To do this, type java -version, then validate with the Enter key. If you see the following line appear: The program java can be found in the following packages, it means that Java is not installed on your computer.
On the other hand, if Java is already installed, you will see a line showing you the installed version

Step 5. Enter the install command
Type:
sudo apt-get install default-jre in the command line, then validate with Enter. Java is then installed on your computer under Ubuntu and its files are in the default directory.
-
If that doesn't work, try entering:
sudo apt-get install openjdk-7-jdk.