Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I uninstall the Java JDK in macOS? [closed]

Tags:

java

macos

People also ask

How do I remove multiple JDK from MAC?

JDK uninstallation process: Copy and paste cd /Library/Java/JavaVirtualMachines and press Enter to open it. Type in ls and press Enter to see the contents of the directory. If you see a jdk file, use the rm prompt to delete it. Type in sudo rm -rf jdk1 and press the Tab key to complete the command.

How do I manually uninstall Java?

Click Start, point to Settings, and then click the Control Panel. In the Control Panel, double-click the Add/Remove Programs. On the Install/Uninstall tab, click the Java version you want to uninstall, and then click Add/Remove. When you are prompted to continue with the Uninstall, click Yes.

Where is the JDK stored on Mac?

In macOS, the JDK installation path is /Library/Java/JavaVirtualMachines/jdk-10. jdk/Contents/Home . The root directory of the JDK software installation. This directory also contains copyright, README, and src.


You can get official oracle instruction to remove java from macOS here

In your macOS terminal type this one by one

sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin 
sudo rm -fr /Library/PreferencePanes/JavaControlPanel.prefPane 
sudo rm -fr ~/Library/Application\ Support/Oracle/Java


After that you can navigate to specific version of java that you intend to delete by using the following command:

cd /Library/Java/JavaVirtualMachines

Then type ls in your terminal to list down all the Java Virtual Machine Folders.
Finally add the version number you want to delete like this

sudo rm -rf jdk-10.0.1.jdk

Instead of jdk-10.0.1.jdk you can give any version number which are listed down in your above mentioned folder.


Update:

  1. First remove the java runtime

    $ sudo mv /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin ~/
    $ sudo mv /Library/PreferencePanes/JavaControlPanel.prefpane ~/
    

    Now you can close and reopen the System Preferences window to see that the icon is gone.

  2. Next, uninstall the Java JDK. Open a terminal and change to the Java directory:

    $ cd /Library/Java/JavaVirtualMachines
    

    You can use ls at the prompt to see what is in the directory and copy the jdk's path name with version number that you wish to delete.

    $ ls --directory *jdk*
    examplejdk-7.jdk
    

    Copy the exact name of the path you want to remove -- for this example it's examplejdk-7.jdk. Next, use that path name inside of single quotes ('examplejdk-7.jdk') to move it to your desktop. Instead of deleting the directory, this moves it to your desktop so you can restore it later in case there's an issue!

    $ sudo mv 'examplejdk-7.jdk' ~/
    
  3. To confirm that it has been removed, run this command:

    $ java
    

    This should output an error message:

    No Java runtime present, requesting install