CentOS 6.0でjdk1.7をインスントールする
1.preのインスントール
cd ~
mkdir data # disk
cd data
mkdir software #
mkdir tar_box #
2.jdkのダウンロード
# cd /data/software
# 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/7u75-b13/jdk-7u75-linux-x64.tar.gz"
Install Java with Alternatives
# cd ..
# tar xzvf /data/software/tar_box/jdk-7u75-linux-x64.tar.gz
# or tar xzvf /tar_box/jdk-7u75-linux-x64.tar.gz
# cd /data/software/jdk1.7.0_75/
# alternatives –install /usr/bin/java java /data/software/jdk1.7.0_75/bin/java 2
# alternatives –config java
Now you may also required to set up javac and jar commands path using alternatives command.
alternatives –install /usr/bin/jar jar /data/software/jdk1.7.0_75/bin/jar 2
alternatives –install /usr/bin/javac javac /data/software/jdk1.7.0_75/bin/javac 2
alternatives –set jar /data/software/jdk1.7.0_75/bin/jar
alternatives –set javac /data/software/jdk1.7.0_75/bin/javac
3.環境設定
cd ~ #.bashrc是在根目录下
vi .bashrc
export JAVA_HOME=/data/software/jdk1.7.0_75
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
source ~/.bashrc
4.設定完了の確認
[root@startnews24 ~]# source ~/.bashrc
[root@startnews24 ~]# echo $JAVA_HOME
/data/software/jdk1.7.0_75
[root@startnews24 ~]#