How to uninstall JDK on Mac OS?

有些话、适合烂在心里 提交于 2019-12-18 11:25:43

问题


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.

I am following the steps listed on this page: 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.

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.

Please share your thoughts on this.


回答1:


From the official Oracle manual.

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.

To remove system files you need to add sudo before rm -rf command.




回答2:


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.

For example:

  • JDK 9
  • JDK 10
  • JDK 11

Also, the files in /usr/bin are not part of the JDK, so you don't really want to remove them. On a system that has never had the JDK installed:

$ 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.




回答3:


If you want to remove JDK from mac you can use the following command:

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 rm -rf jdk1.8.0_06.jdk

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



来源:https://stackoverflow.com/questions/50056598/how-to-uninstall-jdk-on-mac-os

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!