user11744390
user11744390

Reputation:

How to uninstall java from mac completely? JRE and JDK

I did navigate to /Library/Java/JavaVirtualMachines and removed the jdk, and there is nothing in that folder anymore. But my terminal shows I have some version of java, so I am a little confused, I wanna uninstall java completely from my laptop. I did uninstall JRE too using a set of commands.

steps to reproduce

  1. java -version

    output:

openjdk version "1.8.0_152-release"
OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
OpenJDK 64-Bit Server VM (build 25.152-b01, mixed mode)

Upvotes: 12

Views: 67311

Answers (4)

user2506035
user2506035

Reputation: 1

Resolved:

brew tap AdoptOpenJDK/openjdk
brew untap AdoptOpenJDK/openjdk

Upvotes: 0

Gene Pauly
Gene Pauly

Reputation: 1645

The /usr/bin/java and other related tools are macOS shims that run a specific version of Java, as defined by the JAVA_HOME variable.

This variable is usually set in your ~/.bashrc file:

export JAVA_HOME=$(/usr/libexec/java_home -v1.8)`

You can check the current value:

$ echo $JAVA_HOME
/usr/local/Cellar/openjdk@8/1.8.0-392/libexec/openjdk.jdk/Contents/Home

You may have multiple versions of Java installed, to list them all:

$ /usr/libexec/java_home -V
Matching Java Virtual Machines (3):
    21.0.1 (x86_64) "Homebrew" - "OpenJDK 21.0.1" /usr/local/Cellar/openjdk/21.0.1/libexec/openjdk.jdk/Contents/Home
    17.0.9 (x86_64) "Homebrew" - "OpenJDK 17.0.9" /usr/local/Cellar/openjdk@17/17.0.9/libexec/openjdk.jdk/Contents/Home
    1.8.0_392 (x86_64) "Homebrew" - "OpenJDK 8" /usr/local/Cellar/openjdk@8/1.8.0-392/libexec/openjdk.jdk/Contents/Home
/usr/local/Cellar/openjdk/21.0.1/libexec/openjdk.jdk/Contents/Home

In my case, you can see there are three versions of OpenJDK installed via homebrew. I can look them up in the list of installed packages:

$ brew list | grep -iE 'java|jdk|temurin'
openjdk
openjdk@17
openjdk@8

If I wanted to remove all of them, I could do brew uninstall them one by one, or:

$ for pkg in $(brew list | grep -iE 'java|jdk|temurin'); do brew uninstall $pkg; done

Upvotes: 5

mmafrar
mmafrar

Reputation: 371

To uninstall AdoptOpenJDK installed via Homebrew,

brew uninstall adoptopenjdk8

To uninstall OpenJDK installed via Homebrew,

brew uninstall openjdk8

Upvotes: 19

Deepak Patankar
Deepak Patankar

Reputation: 3272

  1. Click on the Finder icon located in your dock
  2. Click on Go in the Finder menu
  3. Click on Utilities
  4. Double-click on the Terminal icon
  5. 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/Oracle/Java

Reference : https://www.java.com/en/download/help/mac_uninstall_java.xml

Upvotes: -2

Related Questions