Install java in centos
1. Download bin file using below command
wget http://download.oracle.com/otn-pub/java/jdk/6u27-b07/jdk-6u27-linux-i586.bin
If the link is not working, Please use the below link, If you need latest one download it.
http://www.oracle.com/technetwork/java/javase/downloads/index.html
2. After download complete it look like
jdk-6u26-linux-x64.bin?e=1312191174&h=c5f0b98f8ea25aca97f3b53be8497570
so we need to rename the file using below command,
mv jdk-6u26-linux-x64.bin?e=1312191174&h=c5f0b98f8ea25aca97f3b53be8497570 jdk-6u4-linux-x64.bin
3. Move the self-extracting file to where you want to install it and extract the file
mv jdk-6u4-linux-x64.bin /opt/
cd /opt
sh jdk-6u4-linux-x64.bin
4. Create a bash script to set JAVA_HOME and add Java executables to the path.
vim /etc/profile.d/java.sh
export JAVA_HOME=/opt/jdk1.6.0_26/
export PATH=$JAVA_HOME/bin:$PATH
5. Source you new script so exports take effect
source /etc/profile.d/java.sh
6. Setup Java to be used by the alternatives system (if you want, or if you have an existing install of Java on your box.
alternatives –install /usr/bin/java java /opt/jdk1.6.0_04/bin/java 2
7. Set this new alternatives as the current configuration
alternatives –config java
Result:
There are 3 programs which provide 'java'. Selection Command ----------------------------------------------- 1 /usr/lib/jvm/jre-1.4.2-gcj/jav + 2 /usr/java/jdk1.6.0_20/bin/java * 3 /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
Just note down the number you are going to use.
2 — alternative number noted in step 6.
After complete the process just conform using
java -version
Note: JAVA FOR 1.6 VERSION
vi /etc/proflie.d/java.sh
export JAVA_HOME=/usr/java/jdk1.6.0_35
export JRE_HOME=/usr/java/jdk1.6.0_35/jre
export PATH=$PATH:/usr/java/jdk1.6.0_35/bin
export CLASSPATH=./:/usr/java/jdk1.6.0_35/lib:/usr/java/jdk1.6.0_35/jre/lib
Note: JAVA FOR 1.7 VERSION
export JAVA_HOME=/usr/jdk1.7.0_09
export JAVA_BIN=/usr/jdk1.7.0_09/bin
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
update-alternatives –install /usr/bin/java java /usr/jdk1.7.0_09/bin/java 300
update-alternatives –install /usr/bin/javac javac /usr/jdk1.7.0_09/bin/javac 300
update-alternatives –config java
Recent Comments