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
- “jre-8u281-linux-x64.tar.gz” which is actually an archive binary file.
- “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:
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.
# mv jre-8u281-linux-x64.tar.gz lh-dir/
This is shown in the screenshot below:
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.
Step 4. Now if you want, you can remove the archive binary (.tar.gz) file as below:
This will help us to save disk space.
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.
Note: Please do not forget to change the name of the directory ‘lh-dir’ to the one you have created.
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.
# java -version
The following screenshot demonstrates this:
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:
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:
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:
The above command will install the JRE rpm file, as shown below:
Step 3. Now again check the version of java from any directory, it will show the following output:
(b) Uninstalling Oracle JRE
Step 1. First, check the installed package of JRE from the following command:
It will show the corresponding jre package:
Step 2. Now uninstall the JRE package with the following command:
Step 3. Now again check the version of java, this time it should show:
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.