Pages

Footer Pages

Spring Boot

Java String API

Java Conversions

Kotlin Programs

Kotlin Conversions

Java Threads Tutorial

Java 8 Tutorial

Friday, November 19, 2021

Uninstall Java on mac os with commands [Fixed]

1. Overview

In this tutorial, we'll learn how to uninstall java version from mac os.

To remove java from mac machine, you can use simple commands.

A) How to remove all versions of java installed on mac
B) How to remove java 11 from mac os.

The second option will work for any java version of mac. It can be either java 7, 8, 10, 11, 1, 13, 0r 14.

Note: you need the administration privileges to mac machine.

Uninstall Java from mac os with commands [Fixed]




2. How to remove all java versions from mac os


First, open launchpad using CMD + Space shortcut key
Next, type terminal and press enter. It will be opened.
Last, run the following commands on the terminal.
sudo rm -rf /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin  
sudo rm -rf /Library/PreferencePanes/JavaControlPanel.prefPane  
sudo rm -rf /Library/Application\ Support/Oracle/Java/ 
sudo rm -rf /Library/Java/JavaVirtualMachines 

All the above commands will delete the java plugins, control panels, jdk, jre and jvm one by one.

After a successful execution above commands, then run the below command which should not show any java version. That means we are all set now.
/usr/libexec/java_home -V

3. How to uninstall Java 11 or any version from mac


First, check the list of available java versions from the terminal using any one of the below commands.

All java versions are displayed on the terminal.

Command 1:

MacBook-Pro-2:CoreJava$ /usr/libexec/java_home -V
Matching Java Virtual Machines (7):
    14.0.1 (x86_64) "AdoptOpenJDK" - "AdoptOpenJDK 14" /Library/Java/JavaVirtualMachines/adoptopenjdk-14.jdk/Contents/Home
    12.0.1 (x86_64) "Oracle Corporation" - "Java SE 12.0.1" /Library/Java/JavaVirtualMachines/jdk-12.0.1.jdk/Contents/Home
    11.0.7 (x86_64) "Oracle Corporation" - "Java SE 11.0.7" /Library/Java/JavaVirtualMachines/jdk-11.0.7.jdk/Contents/Home
    1.8.251.08 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
    1.8.0_252 (x86_64) "AdoptOpenJDK" - "AdoptOpenJDK 8" /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
    1.8.0_251 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home
    1.8.0_161 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home
	/Library/Java/JavaVirtualMachines/adoptopenjdk-14.jdk/Contents/Home


Command 2:
$ ls -l /Library/Java/JavaVirtualMachines/
total 0
drwxr-xr-x  3 root  wheel  96 Jul  5  2020 adoptopenjdk-14.jdk
drwxr-xr-x  3 root  wheel  96 Apr 25  2020 adoptopenjdk-8.jdk
drwxr-xr-x  3 root  wheel  96 May 17  2020 jdk-11.0.7.jdk
drwxr-xr-x  3 root  wheel  96 Jun 23  2019 jdk-12.0.1.jdk
drwxr-xr-x  3 root  wheel  96 Apr 17  2018 jdk1.8.0_161.jdk
drwxr-xr-x  3 root  wheel  96 Apr 27  2020 jdk1.8.0_251.jdk

Now, pick the version that you want to delete. Below are to remove java 8 and java 11.
sudo rm -fr /Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk
sudo rm -fr /Library/Java/JavaVirtualMachines/jdk-11.0.7.jdk

4. Uninstall Java on Mac OS using Brew

From the below with home brew.

The first command to remove the current java version
The second command to remove open JDK 8 version
Use the third command if 2nd one does not work.
$ brew cask uninstall java
$ brew cask uninstall caskroom/versions/adoptopenjdk8
$ brew cask uninstall adoptopenjdk8


5. Conclusion


In this article, we've seen how to uninstall java from mac os using commands and home brew. The commands shown will work for any java version. Even for future releases also.


No comments:

Post a Comment

Please do not add any spam links in the comments section.