CentOS版本:CentOS-7-x86_64-Minimal-1511
1、查看可以安装的openjdk版本
[root@localhost~]# yum search openjdk
2、选择要安装openjdk版本(无需输全称)
[root@localhost~]# yum -y install java-1.8.0-openjdk Dependency installed: … Complete!
3、查看安装情况
[root@localhost~]# java -version openjdk version “1.8.0_111” OpenJDK Runtime Enviroment (build 1.8.0_111-b15) OpenJDK 64-Bit Server VM (build 25.111-b15,mixed mode)
4、卸载openjdk(无需输全称)
[root@localhost~]# rpm -qa|grep jdk java-1.8.0-openjdk-headless-1.8.0.111-1.b15.e17_2.x86_64 java-1.8.0-openjdk-1.8.0.111-1.b15.e17_2.x86_64 [root@localhost~]# yum -y remove java java-1.8.0-openjdk [root@localhost~]# yum -y remove java java-1.8.0-openjdk-headless
5、查看卸载情况
[root@localhost~]# java -version -bash:/bin/java:No such file or directory