3 ways to install Java on Linux

Table of contents:

3 ways to install Java on Linux
3 ways to install Java on Linux
Anonim

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

Install Java on Linux Step 1

Step 1. Go to the Java for Linux page

The site is on this link. Several solutions are proposed to you there.

Install Java on Linux Step 2

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).
Install Java on Linux Step 3

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

Install Java on Linux Step 4

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.

Install Java on Linux Step 5

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.

Install Java on Linux Step 6

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.

Install Java on Linux Step 7

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

Install Java on Linux Step 8

Step 1. Go to the Java for Linux page

The site is on this link. Several solutions are available to you.

Install Java on Linux Step 9

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).
Install Java on Linux Step 10

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

Install Java on Linux Step 11

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.

Install Java on Linux Step 12

Step 5. Enter the root command

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

Install Java on Linux Step 13

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

Install Java on Linux Step 14

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.

Install Java on Linux Step 15

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)

Install Java on Linux Step 17

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 "> _".

Install Java on Linux Step 18

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.

Install Java on Linux Step 19

Step 3. Optionally enter your user password

If asked, type it, then validate with the Enter key.

Install Java on Linux Step 20

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

Install Java on Linux Step 21

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.

Popular by topic