http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
下载Linux版本的JDK,rpm后缀不需要编译
清楚自带的JDK后安装新的JDK
一些开发版的centos会自带jdk,我们一般用自己的jdk,把自带的删除。先看看有没有安装java -version
|
1
2
3
4
|
[root@java-test-01 ~]# java -versionopenjdk version "1.8.0_101"OpenJDK Runtime Environment (build 1.8.0_101-b13)OpenJDK 64-Bit Server VM (build 25.101-b13, mixed mode) |
查找他们的安装位置
|
1
2
3
4
5
6
7
8
|
[root@java-test-01 ~]# rpm -qa | grep javajava-1.8.0-openjdk-headless-1.8.0.101-3.b13.el7_2.x86_64tzdata-java-2016f-1.el7.noarchjava-1.8.0-openjdk-1.8.0.101-3.b13.el7_2.x86_64javapackages-tools-3.4.1-11.el7.noarchjava-1.7.0-openjdk-headless-1.7.0.111-2.6.7.2.el7_2.x86_64java-1.7.0-openjdk-1.7.0.111-2.6.7.2.el7_2.x86_64python-javapackages-3.4.1-11.el7.noarch |
删除全部,noarch文件可以不用删除
|
1
2
3
4
|
[root@java-test-01 ~]# rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.101-3.b13.el7_2.x86_64[root@java-test-01 ~]# rpm -e --nodeps java-1.8.0-openjdk-1.8.0.101-3.b13.el7_2.x86_64[root@java-test-01 ~]# rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.111-2.6.7.2.el7_2.x86_64[root@java-test-01 ~]# rpm -e --nodeps java-1.7.0-openjdk-1.7.0.111-2.6.7.2.el7_2.x86_64 |
检查有没有删除
|
1
2
|
[root@java-test-01 ~]# java -version-bash: /usr/bin/java: 没有那个文件或目录 |
如果还没有删除,则用yum -y remove去删除他们