A Java developer's Mac: four JDKs, three Gradles, and where the rest goes
JDKs, Gradle, Maven and IDE caches each grow separately. What one Mac measured, where each lives, and how to keep one of each instead of four.
The JVM world has more ways to install the same thing than most. A JDK can come from Homebrew, a cask, an installer or an IDE download; Gradle from Homebrew or a project wrapper; and each keeps its own copy.
The map
| What | Measured | Guide |
|---|---|---|
| JDKs, four of them | 1.51 GB | JDKs |
| Gradle caches | 636 MB | Gradle |
| Gradle distributions, three versions | 808 MB | Gradle |
| Maven repository | 44 MB | Maven |
| IDE caches and indexes | not installed | JetBrains caches |
| Android Studio's bundled JDK | not installed | Android Studio |
One of each
- One JDK per major version you target. Remove duplicates, as this Mac had two JDK 17s from different vendors.
- Let projects bring their Gradle. With
./gradleweverywhere, a Homebrew Gradle is only needed for creating new projects. - Old wrapper distributions in
~/.gradle/wrapper/distsbelong to projects that have since upgraded, and can go. - One IDE cache: every IntelliJ version you have upgraded through leaves its own cache folder.
/usr/libexec/java_home -V
ls ~/.gradle/wrapper/dists
du -sh ~/.gradle/* ~/.m2 2>/dev/null | sort -h
ls ~/Library/Caches/JetBrains 2>/dev/nullKotlin Multiplatform adds ~/.konan for native compilers, often over a gigabyte, and cross-compiling for other platforms is covered in cross compilers.
Common questions
How much space does Java development take on a Mac?
On the Mac measured, JDKs were 1.51 GB and Gradle 1.4 GB, before any IDE. IntelliJ's caches add more.
Why do I have several JDKs installed?
Because Homebrew, casks, installers and IDEs each bring their own. The Mac measured had four, including two copies of JDK 17.
Can I delete old Gradle wrapper distributions?
Yes. ~/.gradle/wrapper/dists holds one folder per Gradle version a project asked for, and a project downloads its version again if needed.
Where do IntelliJ caches live on a Mac?
In ~/Library/Caches/JetBrains, with a folder per IDE version. Folders for versions you no longer run can be removed.