How to Install Gradle Build Automation Tool on Ubuntu 22.04

Gradle is an open-source build automation tool based on Groovy and Kotlin. It is mostly used for building Java projects, but it supports multiple languages, including Java, C/C++, and JavaScript. Gradle helps the software developer to build, automate, and deliver software efficiently. Gradle supports both the automatic download of dependencies and many repositories, including Maven and Ivy.

This tutorial will explain how to install Gradle on Ubuntu 22.04.


  • A server running Ubuntu 22.04.
  • A root password is set up for your server.

Update Your System

First, you will need to update all your system packages to the latest version. You can do this by running the following command:

apt update -y
apt upgrade -y

Once all your system packages are updated, install other required packages with the following command.

apt install wget unzip -y

Once you are done, you can proceed to the next step.

Install Java JDK

Gradle is based on Java. So Java JDK must be installed on your system. You can install the latest version of Java by running the following command:

apt install default-jdk -y

After installing Java, you can verify the Java with the following command:

java -version

You should see the following output:

openjdk version "11.0.17" 2022-10-18
OpenJDK Runtime Environment (build 11.0.17+8-post-Ubuntu-1ubuntu222.04)
OpenJDK 64-Bit Server VM (build 11.0.17+8-post-Ubuntu-1ubuntu222.04, mixed mode, sharing)

Install Gradle Using Snap

In this section, we will learn how to install Gradle using Snap.

First, install the Snap package using the following command:

apt install snapd -y

Next, run the following command to install Gradle using the Snap package manager.

snap install gradle --classic

After installing Gradle, you can verify the Gradle installation with the following command:

gradle -v

You should get the following output:

Welcome to Gradle 7.6!

Install Gradle from Source

You can also install Gradle from the source.

Download Gradle

First, change the directory to /opt and download the latest version of Gradle with the following command:

cd /opt/

Once Gradle is downloaded, unzip the downloaded file with the following command:


Next, rename the extracted directory with the following command.

mv gradle-7.6 gradle

You can verify the extracted directory with the following command:

ls /opt/gradle


bin  init.d  lib  LICENSE  NOTICE  README

Configure Gradle Environment Variables

Next, you will need to create a file to define environment variables to use Gradle. Let's create a new file inside /etc/profile.d directory:

nano /etc/profile.d/

Add the following lines:

export GRADLE_HOME=/opt/gradle
export PATH=${GRADLE_HOME}/bin:${PATH}

Save and close the file then set the executable permission with the following command:

chmod +x /etc/profile.d/

Next, load the environment variables with the following command:

source /etc/profile.d/

Verify the Gradle Installation

Gradle is now installed on your system, it's time to verify whether Gradle is installed or not.

You can verify the Gradle installation with the following command:

gradle -v

You should get the following output:

Welcome to Gradle 7.6!

Here are the highlights of this release:
 - Added support for Java 19.
 - Introduced `--rerun` flag for individual task rerun.
 - Improved dependency block for test suites to be strongly typed.
 - Added a pluggable system for Java toolchains provisioning.

For more details see

Gradle 7.6

Build time:   2022-11-25 13:35:10 UTC
Revision:     daece9dbc5b79370cc8e4fd6fe4b2cd400e150a8

Kotlin:       1.7.10
Groovy:       3.0.13
Ant:          Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM:          11.0.17 (Ubuntu 11.0.17+8-post-Ubuntu-1ubuntu222.04)
OS:           Linux 5.15.0-53-generic amd64


Congratulations! you have successfully installed Gradle on Ubuntu 22.04 server. You can now use Gradle in your development environment and start building Java projects. Feel free to ask me if you have any questions.

Share this page:

0 Comment(s)