How to Uninstall Java on Mac
Uninstall Java on Mac by removing the .jdk bundle from /Library/Java/JavaVirtualMachines/ and cleaning up any Homebrew formula. No official uninstaller is required.
Homebrew installs
brew uninstall openjdk@21
# Also remove the symlink:
sudo rm /Library/Java/JavaVirtualMachines/openjdk-21.jdk
List what Homebrew has installed:
brew list | grep openjdk
Adoptium Temurin .pkg installs
# Find the bundle name:
ls /Library/Java/JavaVirtualMachines/
# Remove it (replace temurin-21.jdk with your actual bundle name):
sudo rm -rf /Library/Java/JavaVirtualMachines/temurin-21.jdk
Oracle JDK .pkg installs
Oracle does not include an uninstaller script, so remove manually:
# JDK bundle:
sudo rm -rf /Library/Java/JavaVirtualMachines/jdk-21.jdk
# Oracle system files:
sudo rm -rf /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -rf /Library/PreferencePanes/JavaControlPanel.prefPane
sudo rm -rf ~/Library/Application\ Support/Oracle/Java
Verify removal
/usr/libexec/java_home -V
The uninstalled JDK should no longer appear. If no JDKs remain, the command exits with an error message.
java -version
Should say "No Java runtime present" if all versions were removed.
Clean up ~/.zshrc
If you added JAVA_HOME or PATH entries manually, remove them:
open -e ~/.zshrc # opens in TextEdit
Delete lines containing JAVA_HOME or openjdk, save, and run source ~/.zshrc.