Recommended Free Tools
If a project already contains a gradlew script, you usually don’t need a global Gradle installation to build it. You still need a compatible Java Development Kit (JDK). If you do need a standalone gradle command, you can install it with SDKMAN! or by unpacking the official binary ZIP and adding it to your PATH. The steps below are the documented Linux procedure from Gradle’s own installation guide, applied to an Ubuntu 24.04 machine.
Check for the Gradle Wrapper first
Look in the project root for a gradlew script and a gradle/wrapper directory. If both are there, the project pins its own Gradle version, and you can run tasks with ./gradlew <task>. The Wrapper downloads and runs the configured Gradle version, so a separately installed Gradle is not needed for that project. Gradle’s installation guide puts it directly: “If the gradlew or gradlew.bat files are already present in your project, you do not need to install Gradle.” (Gradle, Inc., Installing Gradle, https://docs.gradle.org/current/userguide/installation.html)
As an Amazon Associate I earn from qualifying purchases.
The Wrapper does not remove the Java requirement. The machine still needs a JDK that the Gradle version supports.
Confirm the Java runtime
Run the following command in a terminal:
java -version
The guide for the current documentation version (Gradle 9.8.0 at the time of writing) states that Gradle requires JDK 17 or newer to run. If java -version reports an older release, or no Java at all, install a supported JDK before going further. On Ubuntu 24.04, the JDK 17 package from the standard repositories is one option:
#1 Best Overall
sudo apt update
sudo apt install openjdk-17-jdk
Gradle chooses a JDK from the environment it runs in, the IDE, or project configuration. If several JDKs are installed, set JAVA_HOME to the one you want Gradle to use, for example:
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
export PATH="$JAVA_HOME/bin:$PATH"
The path above is the usual location for the OpenJDK 17 package on amd64 systems. Confirm yours with ls /usr/lib/jvm before using it.
Choose an installation method
Gradle’s Linux guide documents two routes. They differ mainly in how versions are managed and how much control you keep over the installed files.
| Factor | SDKMAN! (sdk install gradle) |
Manual binary ZIP |
|---|---|---|
| Setup effort | One command, once SDKMAN! itself is installed | Download, unpack, and set PATH yourself |
| Version management | Managed through SDKMAN! | You choose the directory and keep one folder per version |
| Control over installed files | Handled by SDKMAN! | Full: you know exactly where Gradle lives |
| Performance or security difference | Not stated by the source | Not stated by the source |
Use SDKMAN! if you want the shortest path and expect to switch Gradle versions often. Use the manual route if you want a fixed location you can inspect and control.
Option A: install with SDKMAN!
After SDKMAN! is set up in your shell, run:
sdk install gradle
SDKMAN! then makes the installed version available in your shell. Use gradle -v (covered below) to confirm the result.
Option B: install the binary ZIP manually
- Download the binary-only distribution, named
gradle-<version>-bin.zip, from Gradle’s releases page. Gradle’s guide recommends thebinarchive because it is smaller than the full distribution. - Unpack it into a directory you choose. This example uses a directory in your home folder:
mkdir -p "$HOME/opt/gradle" unzip gradle-<version>-bin.zip -d "$HOME/opt/gradle"Replace
<version>with the release you downloaded. The unpacked folder will be$HOME/opt/gradle/gradle-<version>. - Set
GRADLE_HOMEand add itsbindirectory to PATH:export GRADLE_HOME="$HOME/opt/gradle/gradle-<version>" export PATH="$GRADLE_HOME/bin:$PATH" - Verify the command (see the next section).
These export lines apply only to the current shell session. To keep them, add the same two lines to the startup file your shell reads for interactive sessions. In Bash that is often ~/.bashrc, but check which file your terminal actually loads before editing it.
Rank #3
Keeping one directory per version makes upgrades easier: unpack the new release next to the old one, then change GRADLE_HOME to point at the new folder.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsVerify the installation
Run:
gradle -v
The output shows the Gradle version, the build time, the Groovy and Kotlin versions, and the JVM Gradle is running on. Confirm that the JVM line reports a JDK 17 or newer.
Verify the download (optional but recommended)
Gradle publishes a SHA-256 checksum next to each distribution on its releases page. Follow Gradle’s checksum instructions for the file you downloaded. On Ubuntu, you can compute the local hash and compare it with the published value:
Rank #4
sha256sum gradle-<version>-bin.zip
If the two values differ, delete the file and download it again before unpacking it.
Starting a new project
If you are creating a project from scratch rather than cloning one, run gradle init inside the project directory. That command generates the Wrapper files, after which the project can be built with ./gradlew and does not depend on the global installation.
Troubleshooting
gradle: command not found. Thebindirectory is not on PATH in the current shell. Runecho $PATHand confirm it includes$GRADLE_HOME/bin.- The wrong Gradle version runs. Another installation earlier in PATH is taking precedence. Run
which -a gradleto list every match in PATH order. - Gradle fails with a Java or JVM error. The JDK found is missing or older than 17. Run
java -version, then setJAVA_HOMEto a JDK 17 or newer, as described above. - A Gradle package from the Ubuntu or another Linux package manager behaves differently. Gradle’s guide warns that Linux package managers may distribute a modified version that is incompatible or incomplete compared with the official release, and that Gradle, Inc. does not control those packages. If you see unexpected behaviour, try the SDKMAN! or official ZIP route instead.
Scope of these instructions
The procedure above is the general Linux procedure documented by Gradle, Inc. The guide covers Linux in general and does not list Ubuntu 24.04 as a separately tested host, so this article does not claim Ubuntu-specific certification. The steps have been written to work on a standard Ubuntu 24.04 setup, but the version numbers and paths should be checked against the current installation page linked above.
Best Value
Gradle’s documentation changes with each release. The version named here is the one shown in the guide at the time of writing; check the current installation page before pinning a version in scripts or team documentation.
Once gradle -v works, you can use the standalone command for new projects, and rely on ./gradlew for any project that already contains a Wrapper.
Quick Recap
”
The Bottom Line
“”
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




