[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
运行安装
rpm -ivh jdk-7u3-linux-x64.rpm
修改profile 最后面加入
vim /etc/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
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)