- 通过终端执行 /usr/libexec/java_home -V 查找jdk的版本和位置,这里找到jdk文件的名字(我是jdk-23.jdk 第4步会用到)
bash
yyz@ccnn-mac ~ % /usr/libexec/java_home -V
Matching Java Virtual Machines (1):
23.0.1 (arm64) "Oracle Corporation" - "Java SE 23.0.1" /Library/Java/JavaVirtualMachines/jdk-23.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/jdk-23.jdk/Contents/Home
- 依次执行以下:
bash
sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -fr /Library/PreferencesPanes/JavaControlPanel.prefPane
sudo rm -fr ~/Library/Application\ Support/Oracle/Java
-
执行 java -version 检查是否卸载成功(我是没成功)
-
执行 sudo rm -rf /Library/Java/JavaVirtualMachines/jdk-23.jdk 红色部分是需要替换成第一步骤查到的jdk
-
执行 java -version 检查是否卸载成功(成功如下)
bash
yyz@ccnn-mac ~ % java -version
The operation couldn't be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.
可以重新选择java版本安装啦