将解压的文件删除即可,另外再将环境变量删除
[cqzhange@hadoop100 bin]$ java -version java version "1.8.0_212" Java(TM) SE Runtime Environment (build 1.8.0_212-b10) Java HotSpot(TM) 64-Bit Server VM (build 25.212-b10, mixed mode) [cqzhange@hadoop100 bin]$ which java /opt/module/jdk1.8.0_212/bin/java [cqzhange@hadoop100 bin]$ sudo rm -rf /opt/module/jdk1.8.0_212我的环境变量配置在/etc/profile.d/custom.sh
[cqzhange@hadoop100 bin]$ cat /etc/profile.d/custom.sh export JAVA_HOME=/opt/module/jdk1.8.0_212 export PATH=$PATH:$JAVA_HOME/bin export HADOOP_HOME=/opt/module/hadoop-3.1.3 export PATH=$PATH:$HADOOP_HOME/bin export PATH=$PATH:$HADOOP_HOME/sbin删除此文件即可完成卸载操作
[cqzhange@hadoop100 bin]$ sudo rm -rf /etc/profile.d/custom.sh使用下面的命令可批量卸载所有自带的jdk和rpm方式安装的jdk
rpm -qa | grep -i java | xargs -n1 sudo rpm -e --nodeps