Mac storage basics · Programming languages and toolchains
How do I remove old Java JDK versions from my Mac?
Short answer: List JDKs with /usr/libexec/java_home -V, then delete unneeded ones from /Library/Java/JavaVirtualMachines. Use Homebrew to remove any it installed.
Run /usr/libexec/java_home -V in Terminal to list every installed JDK and where it lives — usually /Library/Java/JavaVirtualMachines.
To remove one, delete its folder from that location in Finder (your administrator password is needed). Keep the version your tools and projects use; build tools often download their own JDKs too, which live in their caches (Maven and Gradle caches). If you installed Java through Homebrew, uninstall it with Homebrew instead.