1. DeleteJDK
-
View local
Java JDK
installation location$ /usr/libexec/java_home -V
Matching Java Virtual Machines (1): 21.0.1 (arm64) "Oracle Corporation" - "Java SE 21.0.1" /Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home /Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home
The location is just that
/Library/Java/JavaVirtualMachines/jdk-21.jdk
, the subsequent paths are not needed. -
then delete
$ sudo rm -rf /Library/Java/JavaVirtualMachines/jdk-21.jdk
-
Plug-in deletion status
$ java --version
It says
Java
the environment cannot be found
2. Manually delete other related files
-
In addition to uninstalling
JDK
itself, you can also clean the entire system by manually deleting other related files. These files includeJRE、Java 插件
,Java Web启动器
,Java Web Start
,Java Preferences
andJava Cache
etc. Here are some useful commands and scripts to help delete these files manually. -
delete
JRE
If you want to remove the JRE, follow these steps, first close all applications that are using the JRE. Then enter the following command:
sudo rm -rf /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin sudo rm -rf /Library/LaunchAgents/com.oracle.java.Java-Updater.plist sudo rm -rf /Library/PrivilegedHelperTools/com.oracle.java.JavaUpdateHelper sudo rm -rf /Library/LaunchDaemons/com.oracle.java.JavaUpdateHelper.plist sudo rm -rf /Library/PreferencesPanes/JavaControlPanel.prefPane sudo rm -rf ~/Library/Application\ Support/Oracle/Java
After executing this command, the JRE will be completely deleted.
-
delete
Java 插件
If you want to delete
Java 插件
, please follow the steps below, first close allJava插件
the applications you are using. Then enter the following command:sudo rm -rf /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin sudo rm -rf /Library/PreferencePanes/JavaControlPanel.prefPane
After executing this command,
Java 插件
it will be completely deleted.