Java 如何在 Mac OS 上卸载 JDK?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/50056598/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to uninstall JDK on Mac OS?
提问by Shivank Sharma
Folks - I am facing challenges while trying to uninstall JDK from my MAC (macOS High Sierra Version 10.13.4 - 17E199). I have two JDK instances installed and I want to uninstall both of them.
伙计们 - 我在尝试从我的 MAC(macOS High Sierra 版本 10.13.4 - 17E199)卸载 JDK 时面临挑战。我安装了两个 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.
请分享您对此的看法。
采纳答案by Danila Zharenkov
From the official Oracle manual.
来自官方 Oracle 手册。
Navigate to
/Library/Java/JavaVirtualMachines
and remove the directory whose name matches the following format:/Library/Java/JavaVirtualMachines/jdkmajor.minor.macro[_update].jdk
For example, to uninstall 8u6:
%rm -rf jdk1.8.0_06.jdk
Do not attempt to uninstall Java by removing the Java tools from
/usr/bin
. 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.
导航到
/Library/Java/JavaVirtualMachines
并删除名称与以下格式匹配的目录:/Library/Java/JavaVirtualMachines/jdkmajor.minor.macro[_update].jdk
例如,要卸载 8u6:
%rm -rf jdk1.8.0_06.jdk
不要试图通过从 中删除 Java 工具来卸载 Java
/usr/bin
。此目录是系统软件的一部分,Apple 将在您下次执行操作系统更新时重置任何更改。
To remove system files you need to add sudo before rm -rf command.
要删除系统文件,您需要在 rm -rf 命令之前添加 sudo。
回答by Shawn Carey
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. 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.
这个答案对于 JDK 8 是正确的,但最好指出 Oracle 为 JDK 的每个版本提供不同的说明。某些版本的链接结构略有变化,但通常您可以访问https://docs.oracle.com/en/java/javase,选择您的 JDK 版本,然后在概览组中查找“安装指南”链接。
For example:
例如:
Also, the files in /usr/bin are notpart of the JDK, so you don't really want to remove them. On a system that has never had the JDK installed:
此外,/usr/bin 中的文件不是JDK 的一部分,因此您并不真的想删除它们。在从未安装过 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 中弹出一个对话框。
回答by Chetan kapoor
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/. /Library/Java/JavaVirtualMachines/ is owned by root.
然后使用 sudo 删除 jdk,因为您需要 root 权限才能从 /Library/Java/JavaVirtualMachines/ 中删除 jdk。/Library/Java/JavaVirtualMachines/ 归 root 所有。
sudo rm -rf jdk1.8.0_06.jdk