How to uninstall Java JDK installed without management tools on Mac

1. DeleteJDK

  • View local Java JDKinstallation 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 Javathe environment cannot be found

    image.png

2. Manually delete other related files

  • In addition to uninstalling JDKitself, you can also clean the entire system by manually deleting other related files. These files include JRE、Java 插件, Java Web启动器, Java Web Start, Java Preferencesand Java Cacheetc. Here are some useful commands and scripts to help delete these files manually.

  • deleteJRE

    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.

  • deleteJava 插件

    If you want to delete Java 插件, please follow the steps below, first close all Java插件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.

Guess you like

Origin blog.csdn.net/zz00008888/article/details/135415484