简体   繁体   English

如何在 Mac OS 上卸载 JDK?

[英]How to uninstall JDK on Mac OS?

Folks - I am facing challenges while trying to uninstall JDK from my MAC (macOS High Sierra Version 10.13.4 - 17E199).伙计们 - 我在尝试从我的 MAC(macOS High Sierra 版本 10.13.4 - 17E199)卸载 JDK 时面临挑战。 I have two JDK instances installed and I want to uninstall both of them.我安装了两个 JDK 实例,我想卸载它们。

I am following the steps listed on this page: https://docs.oracle.com/javase/8/docs/technotes/guides/install/mac_jdk.html我正在按照此页面上列出的步骤操作: https : //docs.oracle.com/javase/8/docs/technotes/guides/install/mac_jdk.html

I am trying to run this command in the /Library/Java/JavaVirtualMachines directory which throws an error that I do not have the permission.我试图在 /Library/Java/JavaVirtualMachines 目录中运行此命令,这会引发我没有权限的错误。

rm -rf jdk1.8.0_06.jdk

I am the administrator of the machine and am not sure what more permission do I need.我是机器的管理员,不确定我还需要什么权限。 I have made attempts as the admistrator and as the root user with no success.我以管理员和 root 用户的身份进行了尝试,但没有成功。

Please share your thoughts on this.请分享您对此的看法。

From the official Oracle manual . 来自官方的Oracle手册

Navigate to /Library/Java/JavaVirtualMachines and remove the directory whose name matches the following format: 导航到/Library/Java/JavaVirtualMachines并删除名称与以下格式匹配的目录:

 /Library/Java/JavaVirtualMachines/jdkmajor.minor.macro[_update].jdk 

For example, to uninstall 8u6: 例如,要卸载8u6:

 %rm -rf jdk1.8.0_06.jdk 

Do not attempt to uninstall Java by removing the Java tools from /usr/bin . 不要尝试通过从/usr/bin删除Java工具来卸载Java。 This directory is part of the system software and any changes will be reset by Apple the next time you perform an update of the OS. 此目录是系统软件的一部分,下次执行操作系统更新时,Apple将重置所有更改。

To remove system files you need to add sudo before rm -rf command. 要删除系统文件,您需要在rm -rf命令之前添加sudo。

This answer is correct for JDK 8, but it would be nice to point out that Oracle provides different instructions for each release of the JDK. 这个答案对于JDK 8是正确的,但是指出Oracle为每个JDK版本提供不同的指令会很好。 The link structure changes slightly for some versions, but generally you can go to https://docs.oracle.com/en/java/javase , select your JDK release, and look for the "Install Guide" link in the Overview group. 某些版本的链接结构稍有变化,但通常可以访问https://docs.oracle.com/en/java/javase ,选择JDK版本,然后在Overview组中查找“安装指南”链接。

For example: 例如:

Also, the files in /usr/bin are not part of the JDK, so you don't really want to remove them. 此外,/ usr / bin中的文件不是 JDK的一部分,因此您实际上并不想删除它们。 On a system that has never had the JDK installed: 在从未安装过JDK的系统上:

$ ls -l /usr/bin/java
lrwxr-xr-x  1 root  wheel  74 Sep 27 17:08 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java

$ java -version
No Java runtime present, requesting install.

Apparently macOS includes a baseline version of the JDK, where each command is a stub that just prints this message and pops up a dialog in the GUI. 显然,macOS包含JDK的基线版本,其中每个命令都是一个存根,只打印此消息并在GUI中弹出一个对话框。

If you want to remove JDK from mac you can use the following command: 如果要从mac中删除JDK,可以使用以下命令:

cd /Library/Java/JavaVirtualMachines/

and then use sudo to remove the jdk because you need root permissions to delete jdk from /Library/Java/JavaVirtualMachines/. 然后使用sudo删除jdk,因为你需要root权限才能删除/ Library / Java / JavaVirtualMachines /中的jdk。 /Library/Java/JavaVirtualMachines/ is owned by root. / Library / Java / JavaVirtualMachines /由root拥有。

sudo rm -rf jdk1.8.0_06.jdk

https://installvirtual.com/uninstall-java-8-mac-os-x/ https://installvirtual.com/uninstall-java-8-mac-os-x/

For MacOS - Big Sur | MacOS - Big Sur | Using Terminal使用终端

I was able to remove OpenJDK as per information provided in below link.我能够根据以下链接中提供的信息删除 OpenJDK。

Site Link 网站链接

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM