How to Install Gradle on Ubuntu 26.04 LTS (Resolute Raccoon)
Gradle is the build automation tool behind most modern JVM projects — it’s the default build system for Android, and a common choice for Java, Kotlin, Groovy, and Scala projects that need flexible, incremental, and cacheable builds. This guide walks through installing Gradle 9.6.1 — the current stable release — on Ubuntu 26.04 LTS using SDKMAN!, a manual binary install, and the Gradle Wrapper, so you can pick whichever fits your workflow.
By the end of this tutorial you’ll have Gradle installed and verified, a sample project initialized and built, and the Gradle Wrapper set up so your projects stay reproducible across machines and CI runners.
Table of Contents
- Prerequisites
- Installation Methods Compared
- Architecture: How Gradle Executes a Build
- Method 1: Installing Gradle with SDKMAN! (Recommended)
- Method 2: Manual Installation from Binary Archive
- Method 3: Installing via APT (System Package)
- Verifying the Installation
- Creating and Building Your First Gradle Project
- Using the Gradle Wrapper
- Managing Multiple Gradle Versions
- Speeding Up Builds: Caching and the Daemon
- Troubleshooting
- Uninstalling Gradle
- FAQ
- Related Reads on bckinfo.com
Prerequisites
Before installing Gradle, make sure your Ubuntu 26.04 LTS system meets the following requirements:
- A user account with
sudoprivileges - An active internet connection
- A supported JDK — Gradle 9.x requires JDK 17 or newer to run the Gradle daemon itself, though your project’s compile target can differ via toolchains
- At least 500 MB of free disk space for the JDK and Gradle distribution combined
Ubuntu 26.04 LTS ships without a JDK by default, so install OpenJDK first. JDK 21 is a solid baseline since it’s a current LTS release:
sudo apt update
sudo apt install -y openjdk-21-jdk
Confirm the JDK installed correctly:
java -version
Expected output:
openjdk version "21.0.x" 2026-xx-xx
OpenJDK Runtime Environment (build 21.0.x+xx-Ubuntu-x)
OpenJDK 64-Bit Server VM (build 21.0.x+xx-Ubuntu-x, mixed mode, sharing)
If you manage multiple JDKs on the same machine, sudo update-alternatives --config java lets you switch the active version.
Installation Methods Compared
There are three practical ways to install Gradle on Ubuntu 26.04 LTS.
| Method | Best For | Version Freshness | Multi-Version Support | Root Required |
|---|---|---|---|---|
| SDKMAN! | Developers, CI runners, daily dev work | Latest stable, updated frequently | Yes — switch per shell/project | No |
| Manual Binary Install | Air-gapped servers, reproducible builds, Docker images | Pinned to whatever ZIP you download | Manual (multiple dirs + symlink) | Optional |
APT (gradle package) | Quick system-wide installs, legacy scripts | Often several versions behind upstream | No, single version | Yes |
For day-to-day development, SDKMAN! is the recommended method. That said, most real projects should ultimately rely on the Gradle Wrapper (covered later) rather than a system-wide install, since the Wrapper pins the exact Gradle version per project regardless of what’s installed on the machine.
Architecture: How Gradle Executes a Build
Understanding Gradle’s execution model helps when diagnosing slow or inconsistent builds later.
┌─────────────────────────────────────────────┐
│ Ubuntu 26.04 LTS (OS) │
│ │
│ ┌─────────────────────────────────────┐ │
│ │ OpenJDK 21 (JVM) │ │
│ │ │ │
│ │ ┌────────────────────────────────┐ │ │
│ │ │ Gradle 9.6.1 │ │ │
│ │ │ ─────────────────────────── │ │ │
│ │ │ 1. Initialization │ │ │
│ │ │ tings.gradle[.kts] parsed) │ │ │
│ │ │ 2. Configuration │ │ │
│ │ │ d.gradle[.kts] evaluated, │ │ │
│ │ │ task graph built) │ │ │
│ │ │ 3. Execution │ │ │
│ │ │ s run in dependency order) │ │ │
│ │ └───────────────┬────────────────┘ │ │
│ │ │ │ │
│ │ ▼ │ │
│ │ Gradle Daemon (long-lived JVM) │ │
│ │ Build Cache (local + remote) │ │
│ │ Configuration Cache │ │
│ └─────────────────────────────────────┘ │
└─────────────────────────────────────────────┘
│
┌─────────────────┼──────────────────┐
▼ ▼ ▼
Compiled classes Test reports Published
and JARs (HTML/XML) artifacts
Every Gradle build moves through the same three phases — initialization, configuration, execution — and the long-lived daemon process keeps the JVM warm between builds so subsequent runs start much faster than a cold JVM boot.
Method 1: Installing Gradle with SDKMAN! (Recommended)
SDKMAN! is a version manager for JVM-based SDKs (Gradle, Groovy, Maven, Kotlin, and various JDKs). It installs into your home directory, requires no root access, and makes switching Gradle versions trivial across projects.
Step 1 — Install curl and zip
SDKMAN! depends on curl, unzip, and zip:
sudo apt update
sudo apt install -y curl zip unzip
Step 2 — Install SDKMAN!
curl -s "https://get.sdkman.io" | bash
Load SDKMAN! into your current shell session:
source "$HOME/.sdkman/bin/sdkman-init.sh"
Verify SDKMAN! installed correctly:
sdk version
Step 3 — Install Gradle
List the available Gradle versions if you want to confirm the current release:
sdk list gradle
Install the latest stable release (9.6.1 at the time of writing):
sdk install gradle
To install a specific version instead:
sdk install gradle 9.6.1
SDKMAN! automatically sets the newly installed version as default and updates your PATH and GRADLE_HOME for you — no manual environment variable editing required.
Method 2: Manual Installation from Binary Archive
For servers without internet access to SDKMAN!’s CDN, Docker base images, or environments where you need a pinned, auditable binary, install Gradle manually from the official distribution archive.
Step 1 — Download the binary distribution
cd /tmp
wget https://services.gradle.org/distributions/gradle-9.6.1-bin.zip
Use -all.zip instead of -bin.zip if you also want the source code and documentation bundled locally.
Step 2 — Verify the download (recommended)
Compare the SHA-256 checksum against the value published on the official Gradle releases page:
sha256sum gradle-9.6.1-bin.zip
Step 3 — Extract and install to /opt
sudo mkdir -p /opt/gradle
sudo unzip -d /opt/gradle gradle-9.6.1-bin.zip
This creates /opt/gradle/gradle-9.6.1.
Step 4 — Set environment variables
Create a dedicated profile script so the settings apply system-wide:
sudo nano /etc/profile.d/gradle.sh
Add the following:
export GRADLE_HOME=/opt/gradle/gradle-9.6.1
export PATH=$GRADLE_HOME/bin:$PATH
Apply the changes:
sudo chmod +x /etc/profile.d/gradle.sh
source /etc/profile.d/gradle.sh
Step 5 — (Optional) Symlink for version switching
If you plan to keep multiple manual installs side by side, point /opt/gradle/current at the active version and reference that in GRADLE_HOME instead of a hard-coded version number:
sudo ln -sfn /opt/gradle/gradle-9.6.1 /opt/gradle/current
Then update /etc/profile.d/gradle.sh to use GRADLE_HOME=/opt/gradle/current.
Method 3: Installing via APT (System Package)
Ubuntu’s universe repository ships a gradle package, but it’s typically several versions behind the upstream release and is best reserved for quick, non-critical scripting needs:
sudo apt update
sudo apt install -y gradle
Check the installed version:
apt-cache policy gradle
If you need the current stable release (9.6.x) rather than whatever Ubuntu’s repositories carry, use Method 1 or Method 2 instead.
Verifying the Installation
Regardless of which method you used, confirm Gradle is correctly installed and on your PATH:
gradle -v
Expected output (version details will match what you installed):
------------------------------------------------------------
Gradle 9.6.1
------------------------------------------------------------
Build time: 2026-07-06 xx:xx:xx UTC
Revision: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Kotlin: 2.x.x
Groovy: 4.x.x
Ant: Apache Ant(TM) version 1.10.x
JVM: 21.0.x (Eclipse Adoptium 21.0.x+xx)
OS: Linux 6.x.x amd64
Also confirm GRADLE_HOME resolves correctly (manual install only — SDKMAN! manages this internally):
echo $GRADLE_HOME
which gradle
Creating and Building Your First Gradle Project
Step 1 — Initialize a new project
mkdir hello-gradle && cd hello-gradle
gradle init --type java-application --dsl kotlin --test-framework junit-jupiter
Gradle’s interactive init task can also be run without flags if you’d prefer to be prompted for project type, DSL (Groovy or Kotlin), and test framework choices.
Step 2 — Inspect the generated project
find . -maxdepth 3 -type f
You should see settings.gradle.kts, app/build.gradle.kts, and a generated App.java under app/src/main/java/.
Step 3 — Build and run
gradle build
gradle run
The build task compiles, tests, and packages the project; run executes the generated application directly.
Step 4 — View the test report
xdg-open app/build/reports/tests/test/index.html
(or open the file manually if you’re on a headless server without a desktop environment)
Using the Gradle Wrapper
The Gradle Wrapper (gradlew/gradlew.bat) pins an exact Gradle version to your project so teammates and CI systems don’t need Gradle installed system-wide at all — this is the recommended way to distribute and run Gradle builds in practice.
Generate or update the wrapper
gradle wrapper --gradle-version 9.6.1
This creates gradlew, gradlew.bat, and gradle/wrapper/gradle-wrapper.properties in your project root. Commit all of these to version control.
Build using the wrapper instead of a system install
./gradlew build
Anyone who clones the repository can now run ./gradlew build and get the exact same Gradle version automatically downloaded and used — no manual installation required on their end.
Managing Multiple Gradle Versions
SDKMAN! makes it trivial to keep several Gradle versions installed side by side, useful when maintaining legacy projects pinned to older releases alongside new projects on the latest version:
sdk install gradle 8.14.3
sdk install gradle 9.6.1
sdk use gradle 8.14.3 # switch for the current shell session
sdk default gradle 9.6.1 # set the system-wide default
In practice, once a project has its own Gradle Wrapper committed, the system-wide sdk use/sdk default version only matters for running the initial gradle wrapper command or for projects that don’t ship a wrapper yet.
Speeding Up Builds: Caching and the Daemon
Two features make repeat Gradle builds significantly faster once enabled in gradle.properties (project-level) or ~/.gradle/gradle.properties (user-level):
# Reuse a warm JVM between builds instead of starting a new one each time
org.gradle.daemon=true
# Cache task outputs locally and reuse them across builds/branches
org.gradle.caching=true
# Only reconfigure the build when build scripts actually change
org.gradle.configuration-cache=true
# Run independent tasks in parallel
org.gradle.parallel=true
For teams, a remote build cache (self-hosted or via Gradle’s Develocity product) shares cached task outputs across every developer’s machine and CI agents, so a task built once by any teammate never needs to be rebuilt by anyone else with identical inputs.
Troubleshooting
| Symptom | Likely Cause | Fix |
|---|---|---|
gradle: command not found | PATH not updated, or shell not reloaded | Run source ~/.sdkman/bin/sdkman-init.sh (SDKMAN!) or source /etc/profile.d/gradle.sh (manual install) |
Unsupported class file major version | Project JDK newer than what the installed Gradle version supports | Check the Gradle/JVM compatibility matrix and align your JDK with the Gradle version |
Could not determine java version | JAVA_HOME unset or pointing to a missing path | Run export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java)))) and add it to your shell profile |
| Build hangs on first run after wrapper generation | Wrapper attempting to download a Gradle distribution with no internet access | Pre-populate ~/.gradle/wrapper/dists/ from a machine with internet access, or use an internal Gradle distribution mirror |
sdk: command not found after install | New shell session started before sourcing SDKMAN! init script | Add source "$HOME/.sdkman/bin/sdkman-init.sh" to ~/.bashrc or ~/.zshrc |
| Gradle daemon uses excessive memory over time | Long-lived daemon accumulating state across many builds | Run gradle --stop periodically, or tune -Xmx in org.gradle.jvmargs inside gradle.properties |
apt install gradle installs an old version | Ubuntu universe repo lags upstream releases | Use SDKMAN! or the manual binary method for current releases |
| Configuration cache errors after enabling it | A plugin or build script isn’t yet compatible with configuration caching | Temporarily disable with org.gradle.configuration-cache=false, or check the plugin’s changelog for configuration-cache support |
Uninstalling Gradle
If installed via SDKMAN!:
sdk uninstall gradle 9.6.1
To remove SDKMAN! entirely:
rm -rf "$HOME/.sdkman"
Then remove the SDKMAN! init line from ~/.bashrc or ~/.zshrc.
If installed manually:
sudo rm -rf /opt/gradle
sudo rm /etc/profile.d/gradle.sh
If installed via APT:
sudo apt remove --purge -y gradle
sudo apt autoremove -y
To also clear cached dependencies and the daemon’s state (safe to do regardless of install method):
gradle --stop
rm -rf ~/.gradle
FAQ
Does Ubuntu 26.04 LTS include Gradle by default?
No. Gradle is not part of the base Ubuntu install; it must be added via SDKMAN!, a manual binary install, or the gradle APT package.
Which JDK version should I use with Gradle 9.6.1?
JDK 17 is the minimum required to run Gradle itself. JDK 21 (LTS) is a solid default, and Gradle’s toolchains feature lets you compile against a different JDK version than the one running Gradle.
Should I install Gradle system-wide, or rely on the Wrapper?
For actually building projects, the Wrapper is strongly recommended since it guarantees everyone uses the exact same Gradle version. A system-wide install (via SDKMAN! or manual) is still useful for running gradle init on brand-new projects and for general command-line convenience.
Is Gradle faster than Maven?
Gradle’s incremental build model, build cache, and configuration cache generally make repeat builds significantly faster than Maven’s, especially on large multi-module projects — though a project’s specific plugin usage and cache-hit rate matter more than the tool choice alone.
How do I upgrade an existing project to a newer Gradle version?
Update the Wrapper with gradle wrapper --gradle-version <new-version> (or ./gradlew wrapper --gradle-version <new-version> if a wrapper already exists), then run ./gradlew build and review Gradle’s own upgrade guide for any deprecations affecting your build scripts.







