linux centos 卸载jdk

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
password:
$ 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
 
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)
posted @ 2014-08-25 20:53  mengfanrong  阅读(303)  评论(0编辑  收藏  举报