CentOS 安装jdk1.7 64位
[root@localhost ~]# java -version
java version "1.6.0"
OpenJDK Runtime Environment (build 1.6.0-b09)
OpenJDK 64-Bit Server VM (build 1.6.0-b09, mixed mode)
1.6的,这个必须换掉 。下载jdk-7u3-linux-x64.rpm
# wget http://download.oracle.com/otn-pub/java/jdk/7u3-b04/jdk-7u3-linux-x64.rpm --2012-02-28 00:13:34-- http://download.oracle.com/otn-pub/java/jdk/7u3-b04/jdk-7u3-linux-x64.rpm 正在解析主机 download.oracle.com... 63.97.94.56, 63.97.94.80 Connecting to download.oracle.com|63.97.94.56|:80... 已连接。 已发出 HTTP 请求,正在等待回应... 200 OK 长度:67667318 (65M) [application/x-redhat-package-manager] Saving to: `jdk-7u3-linux-x64.rpm' 65% [===============================================> ] 44,088,409 50.1K/s eta 7m 23s
速度不咋的,可以用迅雷之类的下了传上去。
运行安装
# rpm -ivh jdk-7u3-linux-x64.rpm Preparing... ########################################### [100%] 1:jdk ########################################### [100%] Unpacking JAR files... rt.jar... jsse.jar... charsets.jar... tools.jar... localedata.jar...
# vim /etc/profile
修改profile 最后面加入
export JAVA_HOME=/usr/java/jdk1.7.0_03 export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export PATH=$PATH:$JAVA_HOME/bin
保存退出。运行 #source /etc/profile
之后 运行
# update-alternatives --install /usr/bin/java java /usr/java/jdk1.7.0_03/bin/java 60 # update-alternatives --config java
你会看到我的ssh中存在乱码。
*+ 1 /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java 2 /usr/lib/jvm/jre-1.4.2-gcj/bin/java 3 /usr/java/jdk1.7.0_03/bin/java
输入3 敲回车
然后一切ok
# java -version
java version "1.7.0_03"
Java(TM) SE Runtime Environment (build 1.7.0_03-b04)
Java HotSpot(TM) 64-Bit Server VM (build 22.1-b02, mixed mode)