Java JDKs on a Mac: Homebrew and SDKMAN copies measured, why java_home finds none, and how to remove them

By the Zofle team · 19 November 2026 · 6 min read

Java JDK sizes from Homebrew and SDKMAN on a Mac

Our test Mac had two JDKs installed through Homebrew, 312.7 and 382.7 MB, and <code>/usr/libexec/java_home -V</code> said it could not find a Java Runtime at all. Add three JDKs through SDKMAN (301 to 343 MB each) and the Mac holds five full JDKs that no single command lists. We measured every copy, tested what <code>java_home</code> finds and what it does when you ask for a version it does not have, and removed JDKs with each tool's own command.

What we measured

  • Apple M4 Mac mini, macOS 27.0.1, 19 November 2026. The Homebrew JDKs were already installed: openjdk 27.0.1.0.3 and openjdk@17 17.0.21.0.2.
  • SDKMAN 5.24.0 in a scratch folder under /tmp with a scratch HOME (so nothing touched the real home folder), and Temurin 17.0.21+9, 21.0.13.1+2 and 25.0.5.0+8 from it. SDKMAN's installer needs Bash 4 or newer; macOS ships 3.2, so we added Homebrew's Bash for the run and removed it afterwards.
  • Sizes are du -sk in MB (1 MB = 1,024 KB). We have no Oracle .pkg installer copy here (installing one needs an admin password), so /Library/Java/JavaVirtualMachines stayed empty.

Five JDKs, three places

JDKInstalled byFolderMBFiles
OpenJDK 27.0.1.0.3Homebrew openjdk/opt/homebrew/Cellar/openjdk/373.7305
OpenJDK 17.0.21.0.2Homebrew openjdk@17/opt/homebrew/Cellar/openjdk@17/305.3391
Temurin 17.0.21+9SDKMAN~/.sdkman/candidates/java/17.0.21.0+9-tem309.4456
Temurin 21.0.13.1+2SDKMAN~/.sdkman/candidates/java/21.0.13.1+2-tem334.9456
Temurin 25.0.5.0+8SDKMAN~/.sdkman/candidates/java/25.0.5.0+8-tem294.2400

Homebrew's own listing says 391.3 MB and 319.4 MB for the same two (it counts decimal MB); <code>du</code> gives the 373.7 and 305.3 above. The five together are 1,617.5 MB.

Where the space goes in one JDK: <code>lib/modules</code> is the runtime itself (123.0 MB in Temurin 17, 134.4 MB in 21, 137.9 MB in 25, 139.1 MB in Homebrew's 27). <code>jmods</code> is 70.4 MB in Homebrew's 17 and 81.1 MB in its 27, and it is only needed to build custom runtimes with <code>jlink</code>. Temurin 25 ships without a <code>jmods</code> folder, which is part of why it is the smallest of the three even though it is the newest.

Why java_home says there is no Java

This is the first thing to know on a Mac with Homebrew JDKs. Homebrew's <code>openjdk</code> formula is keg-only: it is not linked into the places macOS looks, and its caveat says to run <code>sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk</code>. Until then:

  • /usr/libexec/java_home -V printed Unable to locate a Java Runtime, exit code 1.
  • /usr/bin/java -version gave the same message.
  • JAVA_HOME was empty.
  • Yet both JDKs run fine when called by path.

SDKMAN copies are invisible to <code>java_home</code> for a different reason: SDKMAN keeps its own <code>current</code> link and sets <code>JAVA_HOME</code> per shell. The Temurin folders have <code>bin</code> and <code>lib</code> at the top level, not the <code>Contents/Home</code> layout macOS expects in a <code>.jdk</code> bundle, so they cannot be linked in either.

We tested the no-admin version of the Homebrew fix: symlinks to the two <code>openjdk.jdk</code> folders in <code>~/Library/Java/JavaVirtualMachines</code>, which <code>java_home</code> also reads. We removed them again afterwards. Then <code>java_home</code> found both, and we asked for versions:

CommandResult
java_home -Vlists 27.0.1.0.3 and 17.0.21.0.2
java_home -v 17the Homebrew 17
java_home -v 21Homebrew 27, exit code 0 (no 21 installed)
java_home -v 28Homebrew 27, exit code 0
java_home -v 1.8Homebrew 27, exit code 0
java_home -v 21 --failfasterror, exit code 1

So <code>export JAVA_HOME=$(/usr/libexec/java_home -v 21)</code> on a Mac without a 21 quietly gives you 27 and a build that now fails in odd ways. Add <code>--failfast</code> in scripts if you want it to stop instead.

Duplicates across installers

  • Two copies of the 17 line: Homebrew's 17.0.21.0.2 (305.3 MB) and Temurin 17.0.21+9 (309.4 MB). Their lib/modules files are both about 123 MB, but they are separate builds, so no clone or hard link shares the space. Keeping both costs 614.7 MB for one Java.
  • Homebrew is behind: brew outdated showed openjdk@17 17.0.21.0.2 → 17.0.21.0.3. An upgrade installs the new folder and, until brew cleanup runs, can leave the old one.
  • gradle depends on Homebrew's openjdk. brew uninstall openjdk refused with required by gradle, which is currently installed. That is Homebrew protecting you; the folder is not a free duplicate if a formula uses it.
  • Not found on this Mac, worth a look on yours: ~/.gradle/jdks, ~/.jdks (IntelliJ downloads), ~/.m2/jdks, and a jbr folder inside JetBrains or Android Studio apps.

Removing JDKs the supported way

WhereCommandWhat we saw
SDKMANsdk uninstall java 21.0.13.1+2-tem966,960 → 623,976 KB: exactly the folder's 342,984 KB
SDKMAN, the default onesdk uninstall java 17.0.21.0+9-temrefused: is the default version. Run sdk default java 25.0.5.0+8-tem first, then it removed 316,864 KB
SDKMAN downloadssdk flush10 archive(s) flushed, freeing 546M
Homebrewbrew uninstall openjdk@17refuses if a formula needs it; brew cleanup removes old versions and downloads
Oracle or other .pkgsudo rm -rf /Library/Java/JavaVirtualMachines/<name>.jdknot tested here (no .pkg JDK installed)

The <code>sdk flush</code> line is the surprise: SDKMAN keeps every downloaded zip in <code>tmp</code>. Our three installs left 558,920 KB there, more than a whole JDK. After the flush the SDKMAN folder went from 1,525,880 KB to 966,960 KB with all three JDKs still installed. Once the 21 and 17 were removed too, only the 25 (307,112 KB with SDKMAN itself) was left.

What to do on your Mac

  • /usr/libexec/java_home -V shows only JDKs macOS can see. Then also run brew list --versions | grep -i -E "jdk|java" and ls ~/.sdkman/candidates/java.
  • Decide which major versions you build against (Maven, Gradle and CI files say) and keep one copy of each line, from one installer.
  • Remove the rest with the tool that installed it, not by deleting folders.
  • Run sdk flush if you use SDKMAN.
  • In scripts, call java_home -v N --failfast so a missing JDK stops the build rather than substituting the newest.

Zofle shows JDK folders from Homebrew, SDKMAN and <code>/Library/Java</code> in one list by size, next to the developer caches covered in our <a href="https://zofle.com/articles/node-version-managers-mac-nvm-fnm-volta-leftover-versions-measured">Node version managers article</a> and our <a href="https://zofle.com/articles/homebrew-mac-storage-cellar-caskroom-cache-cleanup">Homebrew storage article</a>.

Zofle lists JDKs, version managers and developer caches by size on disk and moves your picks to the Trash with Undo.

Download Zofle for Mac

Sources and method

  • Run on 19 November 2026 on one Apple M4 Mac mini, macOS 27.0.1. SDKMAN 5.24.0 (sdkman.io), Temurin builds from SDKMAN's list (sdk list java); Homebrew formulas openjdk and openjdk@17 as already installed. Scratch folders under /tmp were deleted afterwards; the two test symlinks in ~/Library/Java were removed.
  • Sizes are du -sk; one machine, one run. The Homebrew keg-only caveat is quoted from brew info openjdk. The -v fallback behaviour is what we observed with this Mac's two JDKs on macOS 27; we did not read Apple documentation for it and it may differ on other versions.

Zofle Pro news

People signing up now will get Zofle Pro, with more features, for free when we launch it.

One email when it's ready. No spam, ever.