将 jdk1.6 升级到 jdk1.7
下载jdk-7u11-linux-x64.tar.gz
tar zxvf jdk-7u11-linux-x64.tar.gz
mkdir /usr/local/java
mv jdk1.7.0_11/ /usr/local/java/
##修改环境变量,原来的1.6的环境变量修改第一行 为新的 jdk1.7路径,如下:
vi /etc/profile
export JAVA_HOME=/usr/local/java/jdk1.7.0_11
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/jre/lib:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/jre/lib:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar
source /etc/profile
java -version
发现还是1.6
#备份原来的java
mv /usr/bin/java{,.bak}
ln -s -f /usr/local/java/jdk1.7.0_11/jre/bin/java /usr/bin/java
java -version
出现以下信息:
Java version "1.7.0_11"
Java(TM) SE Runtime Environment (build 1.7.0_11-b21)
Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04,mixed mode)
出现以下信息:
Java version "1.7.0_11"
Java(TM) SE Runtime Environment (build 1.7.0_11-b21)
Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04,mixed mode)
升级成功