How to Uninstall Java on Windows, Mac, Linux
Uninstalling Java is straightforward on every OS. Use the standard system uninstall mechanism — Apps & Features on Windows, brew or rm -rf on Mac, apt remove or dnf remove on Linux.
Windows
- Open Settings > Apps > Installed apps.
- Search for "Java", "JDK", "Temurin", "Corretto" or whatever vendor you installed.
- Click the three-dot menu next to each entry and choose Uninstall.
- Repeat for every version listed — Windows keeps each version independent.
- Open a new Command Prompt and run
java -version. It should say "not recognized".
Alternatively, via winget:
winget uninstall EclipseAdoptium.Temurin.21.JDK
macOS
Homebrew installs:
brew uninstall openjdk@21
# Remove the symlink too:
sudo rm /Library/Java/JavaVirtualMachines/openjdk-21.jdk
.pkg installs (Oracle or Temurin):
# Remove the JDK bundle:
sudo rm -rf /Library/Java/JavaVirtualMachines/temurin-21.jdk
# Remove Oracle control panel if present:
sudo rm -rf /Library/PreferencePanes/JavaControlPanel.prefPane
sudo rm -rf ~/Library/Application\ Support/Oracle/Java
Verify removal:
java -version # should fail or fall back to another installed version
Linux (Debian/Ubuntu)
sudo apt remove openjdk-21-jdk openjdk-21-jre
sudo apt autoremove # clean up orphaned packages
Remove all OpenJDK versions at once:
sudo apt remove --purge 'openjdk-*'
sudo apt autoremove
Linux (Fedora/RHEL)
sudo dnf remove java-21-openjdk-devel java-21-openjdk
Manual tarball installs
If you installed Java by extracting a tarball into /opt or ~, just delete the directory:
sudo rm -rf /opt/jdk-21
# Also remove the JAVA_HOME and PATH entries from ~/.bashrc or /etc/profile.d/java.sh
After uninstalling
Remove leftover environment variables: delete or comment out JAVA_HOME and the $JAVA_HOME/bin PATH entry from ~/.bashrc, ~/.zshrc or /etc/environment. Otherwise, PATH may point at a now-missing directory.