在CentOS 6.5 下安装 Sun JDK 1.7。
下载
http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
得到 jdk-7u51-linux-x64.tar.gz
安装
cd /opt
cp /tmp/soft/jdk-7u51-linux-x64.tar.gz .
tar -xzvf jdk-7u51-linux-x64.tar.gz
ln -s /opt/jdk1.7.0_51/bin/java /sbin/java
设置环境变量
echo “export JAVA_HOME=/opt/jdk1.7.0_51” > /etc/profile.d/java_env.sh && echo “export JRE_HOME=/opt/jdk1.7.0_51/jre” >> /etc/profile.d/java_env.sh && echo “export CLASSPATH=.:\$JAVA_HOME/lib:\$JRE_HOME/lib:\$CLASSPATH” >> /etc/profile.d/java_env.sh && echo “export PATH=.:\$JAVA_HOME/bin:\$JRE_HOME/bin:\$PATH” >> /etc/profile.d/java_env.sh
chmod +x /etc/profile.d/java_env.sh
Verify
source /etc/profile.d/java_env.sh
java -version
java version “1.7.0_51”
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
相关阅读:
Ubuntu下安装JDK7(附Clojure下载) http://www.linuxidc.com/Linux/2012-10/71557.htm
Ubuntu 12.04下安装JDK1.7 http://www.linuxidc.com/Linux/2012-06/62239.htm
更多CentOS相关信息见CentOS 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=14