1、下载及安装jdk
cd /usr/local
wget
http://download.oracle.com/otn-pub/java/jdk/6u31-b04/jdk-6u31-linux-i586.bin
chmod 755 jdk-6u31-linux-i586.bin
./jdk-6u31-linux-i586.bin
rm -rf jdk-6u31-linux-i586.bin
2、配置jdk环境变量
1)配置jdk
vi /etc/profile
export JAVA_HOME=/usr/local/jdk1.6.0_31
export PATH=$PATH:$JAVA_HOME/bin
export MANPATH=$JAVA_HOME/man
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/jre/lib/rt.jar
mv /usr/bin/java /usr/bin/java.default
ln -s /usr/local/jdk1.6.0_31/bin/java /usr/bin/java
source /etc/profile
2)验证java环境是否生效
java –version
java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b04)
Java HotSpot(TM) Client VM (build 20.6-b01, mixed mode, sharing)