How to Install Java on Linux

Today's TipsMake will show you how to install the latest version of Java Runtime Environment (JRE) on a computer running the Linux operating system.

Install on Non-RPM Linux

How to Install Java on Linux Picture 1How to Install Java on Linux Picture 1

Open the Java for Linux download page . You will see several options.

How to Install Java on Linux Picture 2How to Install Java on Linux Picture 2

Click Linux . This link is in the middle of the page. The Java installation file will be downloaded.

You can also click on the Linux X64 version if you want to install 64-bit Java.

How to Install Java on Linux Picture 3How to Install Java on Linux Picture 3

Record the file name. The latest Java version is version 8, but you may also need the update version number after the "8u" part at the end of the file name.

For example, your file might be called "jre-8u151", which is version 8, update 151.

How to Install Java on Linux Picture 4How to Install Java on Linux Picture 4

Open the command line. This step will vary depending on your version of Linux, but you can usually find the command line by opening the Terminal app or clicking the bar at the top or bottom of the screen.

How to Install Java on Linux Picture 5How to Install Java on Linux Picture 5

Change installation directory. Type cdinto the console, press spacebar once, then enter the path (e.g. /usr/java/enter then press ↵ Enter.

How to Install Java on Linux Picture 6How to Install Java on Linux Picture 6

Enter the installation command. Type tar zxvf, press spacebar once, then enter the full name of the file. This operation depends on the Java version and when you downloaded it.

As of October 2017, you will have to enter tar zxvf jre-8u151-linux-i586.tar.

How to Install Java on Linux Picture 7How to Install Java on Linux Picture 7

Press ↵ Enter. Java will be installed on the computer in a folder titled "jre1.8.0_[update]" where "[update]", where 'update' is the version number (e.g. 151).

Install on RPM Linux

How to Install Java on Linux Picture 8How to Install Java on Linux Picture 8

Open the Java for Linux download page . You will see several options.

How to Install Java on Linux Picture 9How to Install Java on Linux Picture 9

Click Linux RPM in the middle of the page. The Java installation file for the RPM will be downloaded.

You can also click on the Linux RPM X64 version if you want to install 64-bit Java.

How to Install Java on Linux Picture 10How to Install Java on Linux Picture 10

Record the file name. The latest Java version is version 8, but you may also need the update version number after the "8u" part at the end of the file name.

For example, your file might be called "jre-8u151", which is version 8 and update 151.

How to Install Java on Linux Picture 11How to Install Java on Linux Picture 11

Open the command line. This step will vary depending on your version of Linux, but you can usually find the command line by opening the Terminal app or clicking the bar at the top/bottom of the screen.

How to Install Java on Linux Picture 12How to Install Java on Linux Picture 12

Enter the root command. Type sudo suand press ↵ Enter. The command line will ask for the user password.

How to Install Java on Linux Picture 13How to Install Java on Linux Picture 13

Enter your account password. Type in the account password and press ↵ Enter. As long as you have root (or root) access on the account, this will allow you to install Java.

If you don't have root access on the account, you need to enter the password of the account that has root access.

How to Install Java on Linux Picture 14How to Install Java on Linux Picture 14

Change installation directory. Type cdinto the console, press spacebar once, then enter the path (e.g. /usr/java/enter then press ↵ Enter.

How to Install Java on Linux Picture 15How to Install Java on Linux Picture 15

Enter the installation command. Type rpm -ivh, press space once, enter the full name of the file, then press ↵ Enter. Java will be installed on the computer.

The file name will depend on when you download it. As of October 2017, you will have to enter rpm -ivh jre-8u151-linux-i586.rpmthen press ↵ Enter.

Upgrade downloaded files. Enter rpm -Uvh jre-8u73-linux-i586.rpmand press ↵ Enter. This will check for updates to the Java package and apply them if possible.

Install on Ubuntu (OpenJDK)

How to Install Java on Linux Picture 16How to Install Java on Linux Picture 16

Open the command line. Press Ctrl+ Alt+ Ton your keyboard or click the black frame icon with a white ">_" on the left side of the screen.

How to Install Java on Linux Picture 17How to Install Java on Linux Picture 17

Enter the update command. Type sudo apt-get update && sudo apt-get upgrade -yand press ↵ Enter. The package list will refresh and install all available updates for you.

How to Install Java on Linux Picture 18How to Install Java on Linux Picture 18

Enter your password if asked. If you are asked to enter your user password, enter it and tap ↵ Enter.

How to Install Java on Linux Picture 19How to Install Java on Linux Picture 19

You need to make sure Java is not installed. Enter java -versionand press ↵ Enter. If you see the message "The program 'java' can be found in the following packages" (The java program can be found in the following packages), Java is not installed on your computer.

If Java is installed, you will see a command line reporting the current version of Java on your computer.

How to Install Java on Linux Picture 20How to Install Java on Linux Picture 20

Enter the installation command. Enter sudo apt-get install default-jrethe command line, then press ↵ Enter. Java will be installed into the default directory on the Ubuntu computer.

If this command doesn't work, try entering sudo apt-get install openjdk-8-jdkinstead

Install on Ubuntu 16.04 via PPA

How to Install Java on Linux Picture 21How to Install Java on Linux Picture 21

First of all, this is a third-party installation package, so the Linux distribution's package management system (often referred to as distro) cannot inventory this package, so you need to be careful when using it. CtrlEven so, you still have to press + Alt+ Tto open the terminal first .

How to Install Java on Linux Picture 22How to Install Java on Linux Picture 22

You need to make sure the system is up to date. After entering sudo apt-get update && sudo apt-get upgrade -y, the system will prompt you to enter the password, type the password and press ↵ Enter, note that no dots or asterisks will appear when you enter and this is normal.

Although this step is not technically required, it is always recommended to do it before we install any content, so you should keep the system up to date to limit many problems.

How to Install Java on Linux Picture 23How to Install Java on Linux Picture 23

Add PPA repository to the system. Enter sudo add-apt-repository ppa:webupd8team/javathen press ↵ Enter.

How to Install Java on Linux Picture 24How to Install Java on Linux Picture 24

Update the package lists again. Please type sudo apt-get updateand wait for the packages to be refreshed.

How to Install Java on Linux Picture 25How to Install Java on Linux Picture 25

Install the package. Enter sudo apt-get install oracle-java9-installer -y.

You may be asked to enter your password, then enter it and press ↵ Enter, note that no dots or asterisks will appear as you enter and this is normal.

How to Install Java on Linux Picture 26How to Install Java on Linux Picture 26

Set Oracle's Java as default. On many Ubuntu derivatives, OpenJDK is often the default Java used. If you want Oracle's Java to be used as default, you need to import sudo apt install oracle-java9-set-default.

3.5 ★ | 2 Vote