Igor Kromin |   Consultant. Coder. Blogger. Tinkerer. Gamer.

I've recently had my Mac scanned for a corporate compliance test and the older Java 8 JDK has come up as a failure point. Even though I had newer JDKs installed, it meant that I had to go in and uninstall the one that was making me fail this test. There is good documentation online on how to uninstall a java version on macOS, but I thought that I would walk through the process here anyway...

It looked like I had my default JDK set to the old Java 8 home (running these commands in Terminal.app)...
 Terminal
% java -version
java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)
% grep "export JAVA_HOME" .zprofile
.zprofile:export JAVA_HOME=`/usr/libexec/java_home -v 1.8`


So what I did first was remove that export line from the ~/.zprofile script. Then using the java_home utility, I was able to list all of the java installations that I had...
 Terminal
% /usr/libexec/java_home -V
Matching Java Virtual Machines (4):
14.0.1, x86_64: "Java SE 14.0.1" /Library/Java/JavaVirtualMachines/jdk-14.0.1.jdk/Contents/Home
11.0.7, x86_64: "Java SE 11.0.7" /Library/Java/JavaVirtualMachines/jdk-11.0.7.jdk/Contents/Home
9.0.4, x86_64: "Java SE 9.0.4" /Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home
1.8.0_231, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_231.jdk/Contents/Home


That's quite a few! (also I didn't know that some of these were even installed!)

Using the Terminal.app again, I was able to simply delete the JDKs that I didn't want installed by using the rm command and passing in the Home directory of the JDK to delete (using sudo of course, and entering your admin user password), for example...
 Terminal
sudo rm -rf /Library/Java/JavaVirtualMachines/jdk1.8.0_231.jdk


I proceeded to delete all but the latest JDK using this method. There was nothing else to do after this, the JDK was simply gone!



-i


A quick disclaimer...

Although I put in a great effort into researching all the topics I cover, mistakes can happen. Use of any information from my blog posts should be at own risk and I do not hold any liability towards any information misuse or damages caused by following any of my posts.

All content and opinions expressed on this Blog are my own and do not represent the opinions of my employer (Oracle). Use of any information contained in this blog post/article is subject to this disclaimer.
Hi! You can search my blog here ⤵
NOTE: (2022) This Blog is no longer maintained and I will not be answering any emails or comments.

I am now focusing on Atari Gamer.