0

I've been trying to uninstall all java versions from my mac by following:

% cd /Library/Java/JavaVirtualMachines

when I did ls into JavaVirtualMachines, I saw that there are no folders/ java versions available. However, when I do java --version, there is still a OpenJDK installed on my mac:

openjdk 11.0.17 2022-10-18 LTS
OpenJDK Runtime Environment Corretto-11.0.17.8.1 (build 11.0.17+8-LTS)
OpenJDK 64-Bit Server VM Corretto-11.0.17.8.1 (build 11.0.17+8-LTS, mixed mode)

which java returns /usr/bin/java

Any advice on how I can uninstall this openJDK version?

4
  • Try which java Commented Jul 11, 2023 at 16:34
  • What does which -a java | xargs readlink -f return? (which -a java gives you the paths of all java executables on your PATH, and xargs readlink -f expands any symlinks in those paths).
    – yshavit
    Commented Jul 11, 2023 at 16:35
  • 2
    That said, a quick google of "mac uninstall /usr/bin/java" seems to indicate that the OS really, really wants that to be there. You can jump through some hoops to override it, but you're delving into the realm of "futzing with the OS/distro". Personally, I wouldn't go down that path. Is there a particular reason you want to fully remove Java?
    – yshavit
    Commented Jul 11, 2023 at 16:44
  • Seconding "don't mess with system runtimes". If it's a "Java version management" issue use a Java version manager instead (e.g., asdf, sdkman, jenv, ...). If it's a "I just don't want Java on this machine" do a restart and see where the executable is now. If you manage to remove all Java most likely some things won't work. Commented Jul 11, 2023 at 17:07

1 Answer 1

1

I solved this issue by installing java version manager as suggested by Dave in the comments and it worked! For those having the same issue, I followed this guide https://sma.im/how-to-manage-multiple-java-versions-on-macos/ up to /usr/libexec/java_home -V Then I did /Library/Java/JavaVirtualMachines/ then ls and corretto-11.0.17 showed up and I was able to remove it using rm -rf corretto-11.0.17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .