Skip to content

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.

5 min read

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

WhatMeasuredGuide
JDKs, four of them1.51 GBJDKs
Gradle caches636 MBGradle
Gradle distributions, three versions808 MBGradle
Maven repository44 MBMaven
IDE caches and indexesnot installedJetBrains caches
Android Studio's bundled JDKnot installedAndroid 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 ./gradlew everywhere, a Homebrew Gradle is only needed for creating new projects.
  • Old wrapper distributions in ~/.gradle/wrapper/dists belong 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/null

Kotlin Multiplatform adds ~/.konan for native compilers, often over a gigabyte, and cross-compiling for other platforms is covered in cross compilers.

Related: JetBrains Toolbox old IDE versions on Mac.

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.

Read next