Java used in every device across production and development environment, Java lets you develop and deploy Java applications on desktops and servers. In latest news JDK Java provider Oracle announced as further updates of Java will be available only upon purchasing a subscription for servers or Desktop after January 2019. Let see how to install and configure JDK on RHEL 7 and family servers.



Step 1: Downloading required Java Versions.

To download Oracle Java from command line we need to install with “wget” or “curl”. By default,  In minimal install operating system will not get installed with both packages.

Download URL for Java Oracle JDK 11.0.1

# wget --no-check-certificate --no-cookies --header "Cookie: \
oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/11.0.1+13/90cf5d8f270a4347a95050320eef3fb7/jdk-11.0.1_linux-x64_bin.tar.gz

Download URL for Java Oracle JDK 8u191

# wget --no-check-certificate --no-cookies --header "Cookie: \
oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.tar.gz

List the downloaded tar files.

List the downloaded file.

List the downloaded file.

In case if you need to install the RPM package download with below RPM.

# wget --no-check-certificate --no-cookies --header "Cookie: \
oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/11.0.1+13/90cf5d8f270a4347a95050320eef3fb7/jdk-11.0.1_linux-x64_bin.rpm
# wget --no-check-certificate --no-cookies --header "Cookie: \
oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.rpm# rpm -ivh jdk-11.0.1_linux-x64_bin.rpm

And install with rpm -ivh package_name

# rpm -ivh jdk-8u191-linux-x64.rpm
# rpm -ivh jdk-11.0.1_linux-x64_bin.rpm

Step 2: Extract the downloaded tar file and move to /usr.

Once downloaded with required JDK tar version extract and move the versions under /usr.

# tar -zxf jdk-11.0.1_linux-x64_bin.tar.gz
# tar -zxf jdk-8u191-linux-x64.tar.gz
# mv jdk* /usr/

 

extract the downloaded java tar files

extract the downloaded java tar files





Step 3: Manage Symbolic Links using alternatives.

To install the Java in servers we just need to use alternatives command which will help to maintain symbolic links for any software.

# alternatives --install /usr/bin/java java /usr/jdk1.8.0_191/bin/java 1
# alternatives --install /usr/bin/java java /usr/jdk-11.0.1/bin/java 2

List and verify.

# alternatives --list

 

Alternative to configure Java

The alternative command to configure Java

Select any one of the version using “–config” option.

# alternatives --config java

 

Alternative set Java

Alternative set Java

Verify the Java version.

# java --version

 

Check the Java version

Check the Java version

In case if we need to change to any other available version run with –config command and choose the required version by entering 1 or 2.

# alternatives --config java
# java -version

We have successfully configured two versions of Java, By following let us see how to set the environmental variables for the same.




Step 4: Create an Environmental variable for Java.

In case if your application running under any specific user for security reason we need to configure environmental variable only for the required users under /home/user/.bash_profile.

# vi .bash_profile

Environment variables for Java 8 version

##### Java 8 Environmental Variables #####
JAVA_HOME=/usr/jdk1.8.0_191
PATH=$PATH:$JAVA_HOME/bin
export JAVA_HOME PATH
JRE_HOME=/usr/jdk1.8.0_191/jre/
PATH=$PATH:$JAVA_HOME/bin
export JRE_HOME PATH

Environment variables for Java 11 version

##### Java 11 Environmental Variables #####
JAVA_HOME=/usr/jdk-11.0.1
PATH=$PATH:$JAVA_HOME/bin
export JAVA_HOME PATH

That’s it we have successfully configured Java 8 and 11 in CentOS and RHEL 7 based servers.


Conclusion:

Every developer needs a proper step by step guide to install Java in Linux servers, This guide can be followed in all RPM-based operating systems. To receive more articles related to Linux Subscribe to our newsletter and stay tuned.

Babin Lonston
Overall 13+ Years of experience in IT field, 7+ years of experience in Linux administration with Virtualization & Cloud technologies. Love documentation and being Numismatics for a long time.

How to install Android Studio 3.2.1 on Ubuntu 16.04 LTS/17.10/18.04 LTS

Previous article

Install and configure Apache Tomcat 8.5 on Red Hat7 & CentOS7

Next article

You may also like

Comments

Leave a reply

Your email address will not be published.

More in Linux