I need to un install my JDK 1.8 version from my Mac 12.2.1 Montere. However much I try I could not get rid of it.

When I run $ java -version, I get

openjdk version "1.8.0_322"
OpenJDK Runtime Environment Corretto-8.322.06.1 (build 1.8.0_322-b06)
OpenJDK 64-Bit Server VM Corretto-8.322.06.1 (build 25.322-b06, mixed mode)

When I run $ which java, I get

/usr/bin/java

When I run $ /usr/bin/java -version, I get

openjdk version "1.8.0_322"
OpenJDK Runtime Environment Corretto-8.322.06.1 (build 1.8.0_322-b06)
OpenJDK 64-Bit Server VM Corretto-8.322.06.1 (build 25.322-b06, mixed mode)

When I run $ ls -l /Library/Java/JavaVirtualMachines/ , I get

total 8
-rw-r--r--  1 root  wheel  98 Feb  4 11:10 package-lock.json

When I run $ sudo rm -rf /Library/Java/JavaVirtualMachines/jdk1.8.0_322.jdk

I get to nothing, except being asked for password

I want to manage my Java/JDK installation, management etc. with SDKMAN alone. With homebrew and sdkman it is getting confusing.

1

There are 1 best solutions below

1
On

Following the docs => https://docs.oracle.com/javase/10/install/installation-jdk-and-jre-macos.htm#JSJIG-GUID-F9183C70-2E96-40F4-9104-F3814A5A331F

Note:

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 that you perform an update of the OS.

  1. In your Terminal go to /Library/Java/JavaVirtualMachines.

If the folder does not exists, it can be at higher directory before "/Users"

  1. Remove the directory whose name matches the following format by executing the rm command as a root user or by using the sudo tool

/Library/Java/JavaVirtualMachines/(your jdk1.8.0_322.jdk folder) For example, once inside of JavaVirtualMachines, run:

$ rm -rf jdk1.8.0_322.jdk