How to uninstall Java 9 on macOS Sierra

17,317

Solution 1

After viewing which Java Virtual Machines I had on my computer using the following command:

ls /Library/Java/JavaVirtualMachines

I realized no additional JDK's would appear after using the Java 8 installer (besides Java 9). When doing further research, it turns out I had installed the other version that is not a SE development kit and it was just working in web browsers, not for the terminal.

For anyone having the same issue, make sure you use the Java SE Development Kit 8.

Solution 2

for macOS high sierra removing java 9:

delete the java folder you find in the dir shown to you after executing:

/usr/libexec/java_home -V

use "Go to" in finder and copy and paste the dir to get there

Solution 3

There are two commands which are very simple and useful. If you want to keep multiple versions simply set JAVA_HOME to version you want to use.

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_(version you want to use).jdk/Contents/Home

Example--> export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home

Else in addition to above command remove/uninstall additional jdk version from your system with below command.

sudo rm -rf /Library/Java/JavaVirtualMachines/jdk-(version you want to remove).jdk/

Example --> sudo rm -rf /Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/

Please refer below github link for additional details --> https://gist.github.com/schnell18/bcb9833f725be22f6acd01f94b486392

Thanks

Solution 4

On MacOS you can list what JDKs you have installed and where they are installed to with:

/usr/libexec/java_home -V

If you want to select one of the installed JDKs to be used as default, you can do:

/usr/libexec/java_home -v 1.8

Verify which is now default with java -version.

You can manually add the location of other installed JREs in Eclipse via Preferences / Java / Installed JREs , press Add, and then point it to one of the locations should with the -V option above. You can then check it to select which is default for your projects.

Solution 5

Uninstall Oracle Java using the Terminal:

Note: To uninstall Java, you must have Administrator privileges and execute the remove command either as root or by using the sudo tool. Remove one directory and one file (a symlink), as follows:

Click on the Finder icon located in your dock
Click on the Utilities folder
Double-click on the Terminal icon
In the Terminal window Copy and Paste the commands below:
sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -fr /Library/PreferencePanes/JavaControlPanel.prefPane
sudo rm -fr ~/Library/Application\ Support/Java

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.

Source:https://www.java.com/en/

Share:
17,317
Espin
Author by

Espin

Updated on July 21, 2022

Comments

  • Espin
    Espin almost 2 years

    I'm having trouble removing Java 9 from my macOS Sierra system.

    I accidentally installed Java 9, instead of Java 8, so now all my Eclipse projects give me these warnings: Build path specifies execution environment JavaSE-1.8. There are no JREs installed in the workspace that are strictly compatible with this environment.

    I have used the following guide, but it did not work. Here is my command output when running java -version from the command line:

    java version "9"
    Java(TM) SE Runtime Environment (build 9+181)
    Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)
    
  • Espin
    Espin over 6 years
    I tried just that using the guide I mentioned in my original post, but it didn't work. I still have Java installed.
  • Matt
    Matt over 6 years
    What is the output of /usr/libexec/java_home -V? You have installed the JDK so there is an additional directory for you to remove, namely /Library/Java/JavaVirtualMachines/jdkX.XX.XX.jdk. See these docs: docs.oracle.com/javase/8/docs/technotes/guides/install/…
  • Espin
    Espin over 6 years
    For the first command, the output is Matching Java Virtual Machines (1): 9, x86_64: "Java SE 9" /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home When I went to /Library/Java/JavaVirtualMachines/ there is a jdk-9.jdk, should I remove it?
  • user674669
    user674669 over 6 years
    Simplest answer. Worked great on macOS High Sierra Version 10.13.3
  • Ninja
    Ninja almost 6 years
    i was about to throw my macbook onto the wall. thanks mate, saved my macbook