Java is one of the most used programming languages. Due to its object-oriented nature, it is preferred by developers. Java can be used to develop Mobile, Desktop and Web-based applications. Java allows running java programs on many platforms with the help of JVM. JVM has a JRE or Java Run-time Environment that provides resources and class libraries to Java code for execution. JDK is only needed for developing Java applications.

What’s new in Java SE Release 8 for Linux

  • Support for configuration file along with command-line options for installation with cli. The configuration file-based installation has more options as compared to cli based installation.
  • Commands like java, javap, javac and javadoc can be used by users on the command line.
  • Java SE Release 8 users can now also verify which particular RPM package offers Java files.

What we will Cover

This post will explore Oracle JRE, and we will see how to install Oracle JRE on Fedora Linux using i) an archive binary file ii) an RPM binary file.

We also see how to uninstall JRE in both cases.

Oracle has different versions of JRE for Linux platforms based on system architecture. It is very important to download and install the version specific to your system. The following table shows different versions of Oracle JRE and the system architecture they are built for:

JRE Version System Architecture
jre-8u281-linux-x64.tar.gz 64 bit Linux
jre-8u281-linux-i586.tar.gz 32 bit Linux
jre-8u281-linux-x64.rpm 64 bit RPM based Linux
jre-8u281-linux-i586.rpm 32 bit RPM based Linux

Note: The above naming may change with time as it all depends on the JRE update version number

For this guide, we will be using

  1. “jre-8u281-linux-x64.tar.gz” which is actually an archive binary file.
  2. “jre-8u281-linux-x64.rpm” which is an RPM binary file.

So let’s get started with the installation of Oracle JRE.

Method 1. (a) Installation using archive binary file

Step 1. Open a web browser and go to Oracle JRE download page and download the archive binary file. This is shown below:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/02/echo/image6-4.png" data-lazy- height="446" src="data:image/svg xml,” width=”1395″>

Review and accept the Oracle license agreement. It will now redirect you to the login page before downloading the file. You will need to create a new account with Oracle. If you already have an account, you can login directly.

Step 2. Once the file is downloaded, we can continue further. Beside the root user, any other user can also install the archive binary in any location. But for installing in system location root user is required. We will go to the file download directory and create a new directory as ‘lh-dir’ and move the archive binary to this folder.

# mkdir lh-dir

# mv  jre-8u281-linux-x64.tar.gz lh-dir/

This is shown in the screenshot below:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/02/echo/image10-4.png" data-lazy- height="499" src="data:image/svg xml,” width=”1436″>

You can also use any other location where you would like to install JDK.

Step 3. Now we will unpack the downloaded archive binary in this new directory.

# tar zxvf jre-8u281-linux-x64.tar.gz

Sample Output:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/02/echo/image9-4.png" data-lazy- height="393" src="data:image/svg xml,” width=”1437″>

Step 4. Now if you want, you can remove the archive binary (.tar.gz) file as below:

# rm  jre-8u281-linux-x64.tar.gz

This will help us to save disk space.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/02/echo/image12-2.png" data-lazy- height="249" src="data:image/svg xml,” width=”1177″>

Step 5. To start using JRE from anywhere on the system, we will specify our Java installation path in the /usr/bin directory. The /usr/bin directory contains executable commands on the system.

# update-alternatives –install “https://linuxhint.com/usr/bin/java” “java” “https://linuxhint.com/root/Downloads/lh-dir/jre1.8.0_281/bin/java” 1

Note: Please do not forget to change the name of the directory ‘lh-dir’ to the one you have created.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/02/echo/image11-3.png" data-lazy- height="300" src="data:image/svg xml,” width=”1190″>

Step 6. Once we have specified the java path, we can use the java command from anywhere on the system. Let’s check the java version from the documents folder.

# cd /root/Documents

# java -version

The following screenshot demonstrates this:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/02/echo/image2-5.png" data-lazy- height="303" src="data:image/svg xml,” width=”1193″>

To Check the PATH Variable for the JRE, run the following command:

It will produce output like

(b) Uninstalling Oracle JRE

In case you would like to remove the Oracle JRE from your system, you will need to follow the steps below:

Step 1. Remove all link for the alternatives by running the following command:

# update-alternatives –remove “java” “https://linuxhint.com/root/Downloads/lh-dir/jre1.8.0_281/bin/java”

Please do not forget to change the java file’s location in the above command with your system’s one.

Step 2. Verify if the Oracle JRE has been removed with the below command:

It should say: bash: /usr/bin/java: No such file or directory

Method 2. (a) Installation using the RPM binary file

Step 1. Now again go to the Oracle JRE download page and this time download the 64-bit rpm file as shown below:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/02/echo/image1-5.png" data-lazy- height="475" src="data:image/svg xml,” width=”1337″>

Note: Make sure that before installing the rpm file you have removed the old JDK installation packages.

Step 2. After you have downloaded the file, open a terminal and get root access. Go to the folder containing the rpm file. Now run the following command:

# rpm -ivh jre-8u281-linux-x64.rpm

The above command will install the JRE rpm file, as shown below:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/02/echo/image4-5.png" data-lazy- height="643" src="data:image/svg xml,” width=”1438″>

Step 3. Now again check the version of java from any directory, it will show the following output:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/02/echo/image3-5.png" data-lazy- height="299" src="data:image/svg xml,” width=”1429″>

(b) Uninstalling Oracle JRE

Step 1. First, check the installed package of JRE from the following command:

It will show the corresponding jre package:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/02/echo/image8-4.png" data-lazy- height="239" src="data:image/svg xml,” width=”1435″>

Step 2. Now uninstall the JRE package with the following command:

# rpm -e jre1.8-1.8.0_281-fcs.x86_64

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/02/echo/image5-5.png" data-lazy- height="391" src="data:image/svg xml,” width=”1434″>

Step 3. Now again check the version of java, this time it should show:

bash: /usr/bin/java: No such file or directory

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/02/echo/image7-4.png" data-lazy- height="421" src="data:image/svg xml,” width=”1431″>

Conclusion

In this guide, we have learned how we can install Oracle JRE on Fedora Linux. We have also seen how it can be uninstalled from the system. This guide was successfully tested on Fedora 33 Linux. Since we have installed JRE with .tar.gz file in Method 1, the installation steps will remain the same for all 64 bit Linux distributions.  The same steps should be used for installing Oracle JRE for 32 bit Linux. The only thing to change here is to use the 32-bit version of JRE.

Method 2 is comparatively easy for installing and removing Oracle JRE. The same method should also work on 32-bit Linux by installing the 32-bit version of JRE.

About the author

<img alt="Ali Imran Nagori" data-lazy-src="https://kirelos.com/wp-content/uploads/2021/02/echo/IMG_20201123_090644_2-150×150.jpg6024c5f88aee2.jpg" height="112" src="data:image/svg xml,” width=”112″>

Ali Imran Nagori

Ali imran is a technical writer and Linux enthusiast who loves to write about Linux system administration and related technologies. You can connect with him on LinkedIn


.