How to Install and configure Java JDK on RHEL

Step 1:      Download Oracle Java JDK

  • You can either use the command line or browser to download the JDK, better to use the browser. 
  • Visit the Oracle JDK page to download.

https://www.oracle.com/java/technologies/javase-jdk8-downloads.html

OpenJDK is available from Red Hat Enterprise Linux 8 for x86_64 – AppStream (RPMs) in RHEL 8.

Then you will get a popup. Select the check box and start downloading.

  • To use the command line, use the below command.

                      1.   Install the wget package.

         2.  # wget –no-cookies –no-check-certificate –header “Cookie:  oraclelicense=accept-securebackup-cookie” url

                (Here replace url with oracle java jdk download link)

3.  Extract the downloaded JDK archive to the desired directory    (Ex. /usr/)

Step 2:     Configure Java

  • Install Java with the alternatives commands. Below command will install the Java on your system.

Step 3:    Set Default Oracle Java Version

  • Set the default java using the below command.
  • Select the latest Java:

if your system has multiple versions of Java installed, then the above command may list you all Java versions, like below.  Choose the one Java version to be set default. Enter the number below selection column to select the default Java version. Here, I chose 5 for Oracle JDK 8.

Step 4:         Setup Environment Variable

The most important part has come now, it should be set before the installation of any Java-based applications.

  • To set JAVA environment variables, create a new file under /etc/profile.d directory.
  • Place the variables based on the JDK location and version.
  • Load the environments into the current session.

Step 5:     Verify the Java

  • Once you set up the alternatives.
  • Check the java version installed using the following command.

# java –version

  • This should solve the issue of installation and configuration of Java on Centos or RHEL

Add a Comment

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