Installing and Configuring Oracle Java on CentOS/RHEL/Amazon Linux

This article will guide you through the installation and configuration steps of Java on your CentOS/RHEL/Amazon Linux

The procedure mentioned in this tutorial is implemented on:

OS Amazon Linux
Oracle Java 1.8.0_31


(a) Download Java Package
Download the latest Java JDK 8u31 package from Oracle site using the following command:
For 32bit OS:

# wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u31-b13/jdk-8u31-linux-i586.rpm -P /usr/local/src/


For 64bit OS:

# wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u31-b13/jdk-8u31-linux-x64.rpm -P /usr/local/src/


(b) Installing Java
Now let’s install Java package once it is downloaded, using following command:
For 32bit OS:

# rpm -Uvh /usr/local/src/jdk-8u31-linux-i586.rpm


For 64bit OS:

# rpm -Uvh /usr/local/src/jdk-8u31-linux-x64.rpm 

Sample Output:
Preparing...                          ################################# [100%]
Updating / installing...
   1:jdk1.8.0_31-2000:1.8.0_31-fcs    ################################# [100%]
Unpacking JAR files...
        rt.jar...
        jsse.jar...
        charsets.jar...
        tools.jar...
        localedata.jar...
        jfxrt.jar...


(c) Configuring Oracle Java 8
After installation, let configure Java using “alternatives” package.

# alternatives --install /usr/bin/java java /usr/java/jdk1.8.0_31/jre/bin/java 20000
# alternatives --install /usr/bin/jar jar /usr/java/jdk1.8.0_31/bin/jar 20000
# alternatives --install /usr/bin/javac javac /usr/java/jdk1.8.0_31/bin/javac 20000
# alternatives --install /usr/bin/javaws javaws /usr/java/jdk1.8.0_31/jre/bin/javaws 20000
# alternatives --set java /usr/java/jdk1.8.0_31/jre/bin/java
# alternatives --set javaws /usr/java/jdk1.8.0_31/jre/bin/javaws
# alternatives --set javac /usr/java/jdk1.8.0_31/bin/javac
# alternatives --set jar /usr/java/jdk1.8.0_31/bin/jar

(d) Verifying Oracle Java 8
After Java installation and configuration, lets verify it using following command:

# java -version

Sample Output:
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)


Related Posts:

Install/Setup and Configure Tomcat on CentOS/RHEL/Amazon Linux

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.