Java is the most popular programming language, use to build various type of applications like a desktop application, web application, mobile application, etc. In this article you will learn all the process to install Java on Red Hat 7 Operating system and also learn to install multiple java version and choose one default version of Java in Operating System.

The Java comes in two different packages, one is Java Runtime Environment (JRE), and another one is Java Development Kit (JDK).

When we need to run a Java-based application or java program, we need only Java Runtime Environment, but if you want to develop Java application, you need to Java Development Kit (JDK). JDK includes both JRE and debugging tools and development libraries.

Java also has two different flavors, one is Open JDK, and another one is Oracle Java, both have the same functionalities and capabilities, the only difference is Oracle Java has some more commercial features. The default Java flavor of Linux Operating System is OpenJDK.

If you are a little bit confuse to choose between OpenJDK and Oracle Java, you can stick with default OpenJDK available on RHEL 7.

In this tutorial article, we will walk through the Java installation process on RHEL 7 machine.

Prerequisites

Before continuing this tutorial, make sure you have RHEL 7 installed machine and a user to login into the system with sudo privileges.

OpenJDK Installation

Install OpenJDK 8 JDK

OpenJDK 8 is the most widely-used version of Java. If your application required old version 8 of Java, you could install it by using below command.

Install OpenJDK 8 JRE

If you only want to run a java application, you can install OpenJDK 8 JRE (Java Runtime Environment) by using the following command:

You can verify java installation by checking the version of installed Java, as shown below:

If OpenJDK installed you will get the output like below image:

Check Installed Java version in Red Hat 7 Operating System

Now OpenJDK 8 is installed successfully into your RHEL 7 machine.

Install OpenJDK 11 JDK

OpenJDK 11 is the latest version of Java; you can install it in your RHEL 7 machine by using the following command:

You can verify OpenJDK 11 installation by checking the version of installed java, as shown below:

If OpenJDK installed you will get output like below:

Check Installed Java version in Red Hat 7 Operating System

Install OpenJDK 11 JRE

To run the java application with the latest Java Runtime Environment, you should install OpenJDK 11 JRE by using the following command:

Oracle Java Installation

First, you should be aware of the Oracle Java Licence; it is free only for non-commercial use of the software like development and personal use.

You can download Oracle Java from the official website. You should download Oracle Java “.rpm” packages from the Java SE Downloads page. To download Oracle Java, you have to register on the oracle site.

After downloading “.rpm” package for Oracle Java, You can install it on RHEL 7 by using the following command:

To execute above command first need to download java from official website and use the same rpm file in localinstall command as shown above.

Java default version Setup

If you have installed multiple Java into your RHEL 7 machine, you can check the default version of Java by checking the version, as shown below:

The output of the above command will look like below image:

Check Installed Java version in Red Hat 7 Operating System

You can change the default Java version by using “update-alternatives” command, as shown below:

Configure default Java in Red Hat 7

You will get the list of all installed Java version on your RHEL 7 machine, Enter the number of the version you want to use as a default and press Enter button.

Java Uninstall

If you want to remove Java package from your Red Hat Enterprise Linux system, you can uninstall it like any other application with yum package manager.

To uninstall the java-1.8.0-openjdk-devel package from your Red Hat Enterprise Linux machine, you can use below command:

Conclusion

Now you have learned how to install OpenJDK and Oracle Java on Red Hat Enterprise Linux (RHEL) operating system.

If You Like What We Do Here On LinuxConcept, You Should Consider:

Stay Connected to: Twitter | Facebook

Subscribe to our email updates: Sign Up Now

 

We are thankful for your support.

Follow me

SATISH KUMAR

I am Satish Kumar, Founder of LinuxConcept. Linux and F.O.S.S enthusiast, love to work on open source platform and technologies.
Follow me