When a JDK installation is no longer used, it should be completely removed from the computer. In this quick post, I’d like to share with you how to uninstall JDK entirely from macOS operating system.

 

1. Uninstall Oracle JDK on macOS

If you have a JDK installation that was installed by Oracle JDK installer, you need to find the JDK directory in the/Library/Java/JavaVirtualMachines path. Open a terminal window, change the current directory:

cd /Library/Java/JavaVirtualMachines

Then type ls command to see the installed JDK directories. You may find more than one JDK. Then type the following command to remove a JDK installation completely from macOS:

sudo rm -rf jdk-version

This command will be executed under root privilege (password required) - the specified JDK directory will be deleted recursively and forcefully.

If you uninstall JDK 1.8, you also need to remove 2 other directories using the following commands:

sudo rm -rf /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin

sudo rm -rf /Library/PreferencePanes/JavaControlPanel.prefpane

Then you’re all done.


2. Uninstall OpenJDK on macOS

If you have OpenJDK installation, it’s very likely that it was extracted from an archive file to a specific directory. Open a terminal window, and type which java to see all locations pointing to the java program - it gives you some clues about where the JDK installation directory is.

The simply type the following command to completely uninstall OpenJDK from macOS:



                rm -rf Path/To/OpenJDK

If you got permission denied error, use sudo prefix to run the command under root privilege.

Also consider update system environment variables such as JAVA_HOME and PATH, so it points to the currently installed JDK - not the one has been removed.

That’s my guide about how to completely uninstall JDK on macOS. To see the steps in action, watch the following video:

 

Related Articles:


About the Author:

is certified Java programmer (SCJP and SCWCD). He started programming with Java in the time of Java 1.4 and has been falling in love with Java since then. Make friend with him on Facebook and watch his Java videos you YouTube.



Add comment

   


Comments 

#1rafael gelatti2022-12-08 12:46
Thank you!
Couldn't get rid of OpenJdk. Now I did, thanks
Quote