Install JAVA 7 on CentOS/RHEL
By Anuket Jain On 12 April 2015 In Linux
Use following steps to install Java.
Step 1: Download Archive File
Download latest version of java from its official download page.
For 32 Bit –
# cd /opt/ # 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/7u79-b15/jdk-7u79-linux-i586.tar.gz"
For 64 Bit –
# cd /opt/ # 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/7u79-b15/jdk-7u79-linux-x64.tar.gz"
When download has been completed, Extract tar file using following command.
For 32 Bit – # tar xzf jdk-7u79-linux-i586.tar.gz For 64 Bit – # tar xzf jdk-7u79-linux-x64.tar.gz
Step 2: Install JAVA 7
After extracting tar file, we just need to set up new version of java using alternatives. Use the following commands to do it.
# cd /opt/jdk1.7.0_79/ # alternatives --install /usr/bin/java java /opt/jdk1.7.0_79/bin/java 2 # alternatives --config java
There is 1 program that provides 'java'. Selection Command ----------------------------------------------- *+ 1 /opt/jdk1.7.0_79/bin/java Enter to keep the current selection[+], or type selection number: 1 [Press Enter]
Now we have required to setup javac and jarring using following commands
# alternatives --install /usr/bin/jar jar /opt/jdk1.7.0_79/bin/jar 2 # alternatives --install /usr/bin/javac javac /opt/jdk1.7.0_79bin/javac 2 # alternatives --install /usr/bin/javaws javaws /opt/jdk1.7.0_79/bin/javaws 2 # alternatives --set jar /opt/jdk1.7.0_79/bin/jar # alternatives --set javac /opt/jdk1.7.0_79/bin/javac
Step 3: Check JAVA Version
Use following command to check which version of java.
# java –version
java version "1.7.0_79" Java(TM) SE Runtime Environment (build 1.7.0_79-b17) Java HotSpot(TM) Client VM (build 24.60-b09, mixed mode)
Step 4: Setup Environment Variables
If required then we need to set Java environment variables . Use following commands to set up it.
- Setup JAVA_HOME Variable
# export JAVA_HOME=/opt/jdk1.7.0_79
- Setup JRE_HOME Variable
# export JRE_HOME=/opt/jdk1.7.0_79/jre
- Setup PATH Variable
# export PATH=$PATH:/opt/jdk1.7.0_79/bin:/opt/jdk1.7.0_79/jre/bin
Enjoy it!
Comments
Obrigado pelo tutorial, muito bom.;