1.先看看OpenJDK的安装包
$ rpm -qa |grep java
tzdata-java-2013b-1.el6.noarch
java-1.6.0-openjdk-1.6.0.0-1.61.1.11.11.el6_4.x86_64
java-1.7.0-openjdk-1.7.0.19-2.3.9.1.el6_4.x86_64
2.检查OpenJDK版本
$ java -version
java version "1.7.0_19"
OpenJDK Runtime Environment (rhel-2.3.9.1.el6_4-x86_64)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
3.卸载Openjdk
用root用户登录终端
$ su root
密码:
#rpm -qa|grep java
java-1.7.0-openjdk-1.7.0.19-2.3.9.1.el6_4.x86_64
java-1.6.0-openjdk-1.6.0.0-1.61.1.11.11.el6_4.x86_64
tzdata-java-2013b-1.el6.noarch
$ rpm -e --nodeps java-1.7.0-openjdk-1.7.0.19-2.3.9.1.el6_4.x86_64
$ rpm -e --nodeps java-1.6.0-openjdk-1.6.0.0-1.61.1.11.11.el6_4.x86_64
$ rpm -e --nodeps tzdata-java-2013b-1.el6.noarch
如果上述方式不行的话就直接的使用 : yum remove java
4安装jdk-7u17-linux-x64.rpm
下载地址:http://pan.baidu.com/share/link?shareid=397488&uk=638583574
$ cd /jdk1.7所在目录
$ rpm -ivh jdk-7u17-linux-x64.rpm
Preparing... ########################################### [100%]
1:jdk ########################################### [100%]
Unpacking JAR files...
rt.jar...
Error: Could not open input file: /usr/java/jdk1.7.0_17/jre/lib/rt.pack
jsse.jar...
Error: Could not open input file: /usr/java/jdk1.7.0_17/jre/lib/jsse.pack
charsets.jar...
Error: Could not open input file: /usr/java/jdk1.7.0_17/jre/lib/charsets.pack
tools.jar...
Error: Could not open input file: /usr/java/jdk1.7.0_17/lib/tools.pack
localedata.jar...
Error: Could not open input file: /usr/java/jdk1.7.0_17/jre/lib/ext/localedata.pack
以上那些错误可以忽略,不影响jdk到安装和使用
5.配置环境变量
$vi /etc/profile
输入o,在最后加入以下内容:
JAVA_HOME=/usr/java/jdk1.7.0_17
JRE_HOME=/usr/java/jdk1.7.0_17/jre
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
export JAVA_HOME JRE_HOME PATH CLASSPATH
使环境变量立即生效
$source /etc/profile
6.测试安装是否成功
依次输入java,java -version,javac,看到输出信息即可,例如
[root@chenpc-cent tools]# java -version
java version "1.7.0_17"
Java(TM) SE Runtime Environment (build 1.7.0_17-b02)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
(责任编辑:IT) |