Gradle needs a current JVM before it can run builds, and Ubuntu's repository package can lag far behind the release used by modern Java projects. Installing the official binary distribution under /opt/gradle creates a system gradle command while leaving project-specific Wrapper files free to control individual builds.
The APT packages in this flow install a headless JDK plus the download tools needed for the official distribution. The Gradle ZIP is unpacked into /opt/gradle and exposed through a /usr/local/bin/gradle symlink so normal shells can find it without editing user profile files.
Gradle 9.5.1 requires a supported JVM runtime, and newer Ubuntu releases can select a newer default OpenJDK than older tutorials expect. The final version check must show both the Gradle release and the Launcher JVM so the install proves which Java runtime will launch builds.
Related: How to install JDK on Ubuntu
Related: How to build a Java project with Gradle
$ sudo apt update
$ sudo apt install --no-install-recommends default-jdk-headless curl unzip ca-certificates
Gradle needs a JDK 17 or newer. default-jdk-headless supplies the Ubuntu default JDK without desktop Java packages.
$ java -version openjdk version "25.0.3" 2026-04-21 OpenJDK Runtime Environment (build 25.0.3+9-2-26.04.2-Ubuntu) OpenJDK 64-Bit Server VM (build 25.0.3+9-2-26.04.2-Ubuntu, mixed mode, sharing)
The exact Ubuntu JDK version changes by release and security update. The important result is a JDK version supported by the Gradle release being installed. Related: How to check the installed Java version on Linux
$ GRADLE_VERSION=9.5.1
$ curl --location --fail --silent --show-error \
--output /tmp/gradle-${GRADLE_VERSION}-bin.zip \
https://downloads.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip
The binary-only distribution is enough for running builds. Use the current release from Gradle's releases page when a newer stable version is required.
$ sudo mkdir -p /opt/gradle
$ sudo unzip -q /tmp/gradle-${GRADLE_VERSION}-bin.zip -d /opt/gradle
$ sudo ln -sfn /opt/gradle/gradle-${GRADLE_VERSION}/bin/gradle /usr/local/bin/gradle
The -sfn options update the symlink when the version changes later instead of creating a second command name.
$ command -v gradle /usr/local/bin/gradle
$ gradle --version ------------------------------------------------------------ Gradle 9.5.1 ------------------------------------------------------------ Build time: 2026-05-12 13:19:42 UTC ##### snipped ##### Launcher JVM: 25.0.3 (Ubuntu 25.0.3+9-2-26.04.2-Ubuntu) Daemon JVM: /usr/lib/jvm/java-25-openjdk-arm64 (no Daemon JVM specified, using current Java home) OS: Linux 6.12.76-linuxkit aarch64
The Launcher JVM line is the decisive Java runtime check. If it points to the wrong JDK, fix the active java command or JAVA_HOME before using Gradle for builds.
$ mkdir -p /tmp/gradle-smoke
$ cd /tmp/gradle-smoke
$ gradle help --no-daemon To honour the JVM settings for this build a single-use Daemon process will be forked. ##### snipped ##### BUILD SUCCESSFUL in 3s
$ cd ~
$ rm -r /tmp/gradle-smoke /tmp/gradle-${GRADLE_VERSION}-bin.zip