How to install Oracle Java (JDK/JRE) 8/11/12 in Linux?

JAVA is necessary to run Java based applications in Linux and windows machine.

JAVA comes with two packages (JDK & JRE).

JDK stands for (Java Development Kit) which helps developers for developing, debugging, and monitoring Java applications.

JRE stands for (Java Runtime Environment) which deploys Java applications on servers.

It included tools for JVM monitoring which commonly required for server applications.

In this article we are going to explain how to install oracle java on CentOS, Fedora, openSUSE and Arch Linux systems.

The JDK package contains JRE too, so no need to download separately. openJDK project is sponsor by oracle.

We have already covered few articles about openJDK & Oracle JAVA, hit the below link for further reading.

Suggested Read : openJDK & Oracle JAVA Related Articles

1) How to download Oracle Java rpm file?

Use the below command to download the oracle java rpm files. Make sure oracle uses cookies, so use the wget command according that, like below format.

Also check with oracle website for latest version of oracle java download.

Run the following command to download the latest available oracle java 8.

$ sudo wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "https://download.oracle.com/otn/java/jdk/8u212-b10/59066701cf1a433da9770636fbc4c9aa/jdk-8u212-linux-x64.rpm"

Run the following command to download the latest available oracle java 11.

$ sudo wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "https://download.oracle.com/otn/java/jdk/11.0.3+12/37f5e150db5247ab9333b11c1dddcd30/jdk-11.0.3_linux-x64_bin.rpm"

Run the following command to download the latest available oracle java 12.

$ sudo wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "https://download.oracle.com/otn-pub/java/jdk/12.0.1+12/69cfe15208a647278a19ef0990eea691/jdk-12.0.1_linux-x64_bin.rpm"

2) How to install Oracle Java in Linux?

Use the below RPM Command to Install oracle java 8 into rpm based systems such as RHEL, CentOS, Fedora & openSUSE.

For Oracle Java 8.

$ sudo rpm -ivh jdk-8u212-linux-x64.rpm

For Oracle Java 11.

$ sudo rpm -ivh jdk-11.0.3_linux-x64_bin.rpm

For Oracle Java 12.

$ sudo rpm -ivh jdk-12.0.1_linux-x64_bin.rpm

3) How to install Oracle Java 11/12 on Arch Linux?

Oracle java latest version are available in AUR repository. Hence, we can easily install it on arch Linux based system using AUR helper such as yay.

$ yay -Ss oracle java
aur/jre11 11.0.3-1 (+0 0.00%) 
    Oracle Java 11 Development Kit
aur/jdk11 11.0.3-1 (+1 0.41%) 
    Oracle Java 11 Development Kit
aur/jre 12.0.1-1 (+598 4.08%) 
    Oracle Java Runtime Environment
aur/jdk 12.0.1-1 (+795 2.79%) 
    Oracle Java Development Kit

The above output will show you the list of available Oracle JDK and JRE versions. Just type the number of your choice to get install it.

4) How to check installed Java Version in Linux?

Run the following command on terminal to check the installed java version on your system.

$ java -version
java version "9.0.1"
Java(TM) SE Runtime Environment (build 9.0.1+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)

5) How to setup up JAVA Environment Variables in Linux?

Make sure you have to Setup JAVA Environment Variables for java as java based applications uses environment variables to work.

Open your .bashrc file and add the below lines to end of the file. Make sure you mentioned your  system path instead of ours, then save and exit.

$ nano .bashrc
JAVA_HOME="/usr/java/jdk-9.0.1/bin/java"
PATH=$PATH:$HOME/bin:JAVA_HOME

After saving .bashrc file, run the following command to make it work

$ source ~/.bashrc

Now, check the environment value using below command, which clearly fetch the path of jdk home.

$ echo $JAVA_HOME
/usr/java/jdk-9.0.1/bin/java

About Prakash Subramanian

Prakash Subramanian is a Linux lover and has 3.5+ years of experience in linux server administration with major Linux distribution such as (RHEL, CentOS, Ubuntu). He is currently working as a Senior L2 Linux Server administrator.

View all posts by Prakash Subramanian

9 Comments on “How to install Oracle Java (JDK/JRE) 8/11/12 in Linux?”

Leave a Reply to bob Cancel reply

Your email address will not be published. Required fields are marked *