Sep 072015
 

Java

Today we will be looking into the installation of Oracle Java SDK 1.8_u5 on RHEL / CentOS, Java SDK is the most important base to the developers; this guide will be more useful for them to setup development environment when they especially uses Redhat or CentOS.

Download Java SDK:

You can either use command line or browser to download the JDK, better to use the browser, the easiest one. Visit the Oracle SDK page to download. If you still want to use the command line, use the below command.

# wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u11-b12/jdk-8u11-linux-x64.tar.gz
# tar -zxvf jdk-8u11-linux-x64.tar.gz
 
#  mv jdk1.8.0_11/ /usr/

Install Java:

Once moved the java to the desired location, java must setup with the alternatives commands; this will install the java on your system.

# /usr/sbin/alternatives --install /usr/bin/java java /usr/jdk1.8.0_11/bin/java 2
 
# /usr/sbin/alternatives --config java

Select the latest java.

There are 2 programs which provide 'java'.
 
  Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.51-2.4.5.5.el7.x86_64/jre/bin/java
   2           /usr/jdk1.8.0_11/bin/java
 
Enter to keep the current selection[+], or type selection number: 2

Verify the Java:

Once setup the alternatives, verify the java version installed using the following command.

# java –version
 
java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)

Setup Environmental Variable:

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

# export JAVA_HOME=/usr/jdk1.8.0_11/
 
# export JRE_HOME=/usr/jdk1.8.0_11/jre/

Set PATH variable too.

# export PATH=$JAVA_HOME/bin:$PATH

To set it as a permanent, place the above three commands in the /etc/profile (All Users) or .bash_profile (Single User)

That’s All!. Hope this helped, place your valuable comments below.