A Java Development Kit (JDK) is a program development environment it’s released by Oracle Corporation. This binary package used for compile java application, debug, run Java applets and applications.
We can install Java 7 (JDK 7u60) or Java 8 (JDK 8u25) in CentOS, Fedora, RHEL and other Linux related operating system.
This post describe install JDK 8u25 with 64 bit
Step 1: Download the packages as you like java 7 or java 8,
# mkdir /opt/java
# cd /opt/java
# cd /opt/java
For JDK 7u60 64 Bit:
$ wget --no-check-certificate --no-cookies - --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u67-b01/jdk-7u67-linux-i586.tar.gz"
$ wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u60-b19/jdk-7u60-linux-i586.rpm"
For JDK 7u60 32 Bit:
$ wget --no-check-certificate --no-cookies - --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u67-b01/jdk-7u67-linux-i586.tar.gz"
$ wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u60-b19/jdk-7u60-linux-i586.rpm"
For JDK 8u25 64 Bit:
$ wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jdk-8u25-linux-x64.tar.gz"
$ wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u65-b17/jdk-8u65-linux-x64.rpm
For JDK 8u25 32 Bit:
$ wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jdk-8u25-linux-i586.tar.gz"
$ wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u25-b17/jdk-8u25-linux-i586.rpm"
Step 2: Install tar.gz file
If you have download the file with tar.gz format just extact under /opt or /usr/java directories For example,
# mkdir /usr/java
# tar -xf jdk-8u25-linux-x64.tar.gz
# mv jdk1.8.0_25 /usr/java/.
# tar -xf jdk-8u25-linux-x64.tar.gz
# mv jdk1.8.0_25 /usr/java/.
Step 3: Install RPM
Note : If you have downloaded RPM package follow below step,
Install Java 7 .rpm package,
# rpm -ivh jdk-7u60-linux-x64.rpm
Preparing... ############### [100%]
1:jdk ############### [100%]
Unpacking JAR files...
rt.jar...
jsse.jar...
charsets.jar...
tools.jar...
localedata.jar...
jfxrt.jar...
Set JAVA_HOME path,
# export JAVA_HOME=/usr/java/jdk1.7.0_60
# export JRE_HOME=/usr/java/jdk1.7.0_60/jre
# export PATH=$PATH:/usr/java/jdk1.7.0_60/bin:/usr/java/jdk1.7.0_60/bin
# export JRE_HOME=/usr/java/jdk1.7.0_60/jre
# export PATH=$PATH:/usr/java/jdk1.7.0_60/bin:/usr/java/jdk1.7.0_60/bin
You can check the path,
# echo $JAVA_HOME
/usr/java/jdk1.7.0_60
# echo $JRE_HOME
/usr/java/jdk1.7.0_60/jre
# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:.....
/usr/java/jdk1.7.0_60
# echo $JRE_HOME
/usr/java/jdk1.7.0_60/jre
# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:.....
Install Java 8 package using alternatives command,
# alternatives --install /usr/bin/java java /opt/jdk1.8.0_25/bin/java 2
# alternatives --config java
# alternatives --config java
There are 2 programs which provide 'java'.
Selection Command
-----------------------------------------------
*+ 1 /opt/jdk1.7.0_67/bin/java
2 /opt/jdk1.8.0_25/bin/java
Enter to keep the current selection[+], or type selection number: 2
Check your Java Version
# java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
Find Java installed location:
# whereis java
java: /usr/bin/java /opt/jdk1.8.0_25/bin/java
The Java 8 has been installed successfully installed in your system.
Step 4 : Additional setup:
Now, we need to setup javac and jar commands path using same command,
# alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_25/bin/jar 2
# alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_25/bin/javac 2
# alternatives --set jar /opt/jdk1.8.0_25/bin/jar
# alternatives --set javac /opt/jdk1.8.0_25/bin/javac
# alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_25/bin/javac 2
# alternatives --set jar /opt/jdk1.8.0_25/bin/jar
# alternatives --set javac /opt/jdk1.8.0_25/bin/javac
Step 5: Setup JAVA_Home path:
# JAVA_HOME=/opt/jdk1.8.0_25
# export JAVA_HOME
# PATH=$JAVA_HOME/bin:$PATH
# export PATH
# export JAVA_HOME
# PATH=$JAVA_HOME/bin:$PATH
# export PATH
Another option is,
# export JAVA_HOME=/opt/jdk1.8.0_25
# export JRE_HOME=/opt/jdk1.8.0_25/jre
# export PATH=$PATH:/opt/jdk1.8.0_25/bin:/opt/jdk1.8.0_25/jre/bin
# export JRE_HOME=/opt/jdk1.8.0_25/jre
# export PATH=$PATH:/opt/jdk1.8.0_25/bin:/opt/jdk1.8.0_25/jre/bin
Check your $JAVA_HOME path,
# echo $JAVA_HOME
/opt/jdk1.8.0_25
Comments (0)