念念不忘
必有回响

macOS卸载JDK

一、使用pkgutil

使用如下命令即可查看使用Pkg安装的JDK信息:

pkgutil --pkgs |grep jdk
com.oracle.jdk-9.0.4
com.oracle.jdk8u161
com.oracle.jdk8u102
com.oracle.jdk7u79
com.oracle.jdk-10
com.oracle.jdk8u131
com.oracle.jdk-9

二、查看关联文件

进入/private/var/db/receipts目录查看pkg文件的关联信息

cd /private/var/db/receipts
ls *.jdk*.bom

com.oracle.jdk-10.bom    com.oracle.jdk7u79.bom
com.oracle.jdk-9.0.4.bom com.oracle.jdk8u161.bom

三、删除JDK目录

进入/Library/Java/JavaVirtualMachines路径,删除要删除的JDK版本的目录

cd /Library/Java/JavaVirtualMachines

ls 

jdk-10.jdk       jdk-9.0.4.jdk    jdk1.7.0_79.jdk  jdk1.8.0_161.jdk
sudo rm -fr jdk1.7.0_79.jdk

接着根据第二步执行命令的结果,执行如下命令:

lsbom -fls com.oracle.jdk8u91.bom|(cd /; sudo xargs rm)

此命令会提示大量的No such file or directory 例如:

rm: ./Contents/Home/man/ja_JP.UTF-8/man1/schemagen.1: No such file or directory
rm: ./Contents/Home/man/ja_JP.UTF-8/man1/serialver.1: No such file or directory
rm: ./Contents/Home/man/ja_JP.UTF-8/man1/servertool.1: No such file or directory
rm: ./Contents/Home/man/ja_JP.UTF-8/man1/tnameserv.1: No such file or directory
rm: ./Contents/Home/man/ja_JP.UTF-8/man1/unpack200.1: No such file or directory
rm: ./Contents/Home/man/ja_JP.UTF-8/man1/wsgen.1: No such file or directory
rm: ./Contents/Home/man/ja_JP.UTF-8/man1/wsimport.1: No such file or directory
rm: ./Contents/Home/man/ja_JP.UTF-8/man1/xjc.1: No such file or directory

也可以不执行。

然后执行如下命令让系统彻底删除该信息

sudo pkgutil --forget com.oracle.jdk7u79

当然,如果本地只安装了一个JDK,那么还需要删除如下路径:

sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin

 

赞(0) 打赏
未经允许不得转载:码农志 » macOS卸载JDK
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏