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.

Steps to install Gradle on Ubuntu:

  1. Refresh the local APT package lists.
    $ sudo apt update
  2. Install the headless JDK and download tools.
    $ 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.

  3. Confirm that Java runs before installing Gradle.
    $ 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

  4. Set the Gradle version for the install session.
    $ GRADLE_VERSION=9.5.1
  5. Download the official Gradle binary distribution.
    $ 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.

  6. Create the system install directory.
    $ sudo mkdir -p /opt/gradle
  7. Unpack the Gradle distribution under /opt/gradle.
    $ sudo unzip -q /tmp/gradle-${GRADLE_VERSION}-bin.zip -d /opt/gradle
  8. Expose the selected Gradle binary on the system path.
    $ 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.

  9. Confirm the active Gradle command path.
    $ command -v gradle
    /usr/local/bin/gradle
  10. Confirm the Gradle release and JVM.
    $ 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.

  11. Create a temporary smoke-test directory.
    $ mkdir -p /tmp/gradle-smoke
  12. Enter the smoke-test directory.
    $ cd /tmp/gradle-smoke
  13. Run the Gradle help task without keeping a daemon running.
    $ 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
  14. Return to the home directory.
    $ cd ~
  15. Remove the temporary download and smoke-test directory.
    $ rm -r /tmp/gradle-smoke /tmp/gradle-${GRADLE_VERSION}-bin.zip