1. 首先查看系统自带的JDK版本:
[root@linux ~]# java -version
java version "1.6.0"
2. 确定JDK的具体版本号,然后将其卸载:
[root@linux ~]# rpm -qa | grep jdk
[root@linux ~]# rpm -qa | grep gcj
上面先确认jdk的具体版本号,然后使用rpm -e –nodeps命令删除上面查找的内容:
#rpm -e –nodeps java-1.6.0. …
… Complete!
3. 再次检查JDK版本,卸载成功:
[root@linux ~]# java -version
-bash: ./usr/bin/java: No such file or directory
4.通过yum 查询可以安装的版本
[root@linux ~]# yum -y list java*
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.ustc.edu.cn
* extras: centos.ustc.edu.cn
* updates: centos.ustc.edu.cn
base | 3.7 kB 00:00
extras | 3.4 kB 00:00
updates | 3.4 kB 00:00
Available Packages
java-1.5.0-gcj.x86_64 1.5.0.0-29.1.el6 base
java-1.5.0-gcj-devel.x86_64 1.5.0.0-29.1.el6 base
java-1.5.0-gcj-javadoc.x86_64 1.5.0.0-29.1.el6 base
java-1.5.0-gcj-src.x86_64 1.5.0.0-29.1.el6 base
java-1.6.0-openjdk.x86_64 1:1.6.0.40-1.13.12.6.el6_8 updates
java-1.6.0-openjdk-demo.x86_64 1:1.6.0.40-1.13.12.6.el6_8 updates
java-1.6.0-openjdk-devel.x86_64 1:1.6.0.40-1.13.12.6.el6_8 updates
java-1.6.0-openjdk-javadoc.x86_64 1:1.6.0.40-1.13.12.6.el6_8 updates
java-1.6.0-openjdk-src.x86_64 1:1.6.0.40-1.13.12.6.el6_8 updates
java-1.7.0-openjdk.x86_64 1:1.7.0.111-2.6.7.2.el6_8 updates
java-1.7.0-openjdk-demo.x86_64 1:1.7.0.111-2.6.7.2.el6_8 updates
java-1.7.0-openjdk-devel.x86_64 1:1.7.0.111-2.6.7.2.el6_8 updates
java-1.7.0-openjdk-javadoc.noarch 1:1.7.0.111-2.6.7.2.el6_8 updates
java-1.7.0-openjdk-src.x86_64 1:1.7.0.111-2.6.7.2.el6_8 updates
java-1.8.0-openjdk.x86_64 1:1.8.0.101-3.b13.el6_8 updates
java-1.8.0-openjdk-debug.x86_64 1:1.8.0.101-3.b13.el6_8 updates
java-1.8.0-openjdk-demo.x86_64 1:1.8.0.101-3.b13.el6_8 updates
java-1.8.0-openjdk-demo-debug.x86_64 1:1.8.0.101-3.b13.el6_8 updates
java-1.8.0-openjdk-devel.x86_64 1:1.8.0.101-3.b13.el6_8 updates
java-1.8.0-openjdk-devel-debug.x86_64 1:1.8.0.101-3.b13.el6_8 updates
java-1.8.0-openjdk-headless.x86_64 1:1.8.0.101-3.b13.el6_8 updates
java-1.8.0-openjdk-headless-debug.x86_64 1:1.8.0.101-3.b13.el6_8 updates
java-1.8.0-openjdk-javadoc.noarch 1:1.8.0.101-3.b13.el6_8 updates
java-1.8.0-openjdk-javadoc-debug.noarch 1:1.8.0.101-3.b13.el6_8 updates
java-1.8.0-openjdk-src.x86_64 1:1.8.0.101-3.b13.el6_8 updates
java-1.8.0-openjdk-src-debug.x86_64 1:1.8.0.101-3.b13.el6_8 updates
java_cup.x86_64 1:0.10k-5.el6 base
java_cup-javadoc.x86_64 1:0.10k-5.el6 base
java_cup-manual.x86_64 1:0.10k-5.el6 base
javacc.x86_64 4.1-0.5.el6 base
javacc-demo.x86_64 4.1-0.5.el6 base
javacc-manual.x86_64 4.1-0.5.el6 base
javassist.noarch 3.9.0-6.el6 base
javassist-javadoc.noarch 3.9.0-6.el6 base
5.升级安装
[root@cloud ~]# yum install java-1.8.0-openjdk.x86_64
6.再次版本确认
[root@linux ~]# java -version