Uninstalling Java JDK from macOS
How to properly remove a Java JDK installation from macOS without breaking system tools.
To uninstall a JDK from macOS, you need Administrator privileges. Navigate to the JDK directory and remove it:
cd /Library/Java/JavaVirtualMachines
sudo rm -rf jdk1.8.0_06.jdk
Replace the version number with the one you want to remove. The naming format is:
jdkmajor.minor.macro[_update].jdk
Important: 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 you perform an OS update.