How To Install Gradle Build Tool on Debian 11

In this guide, we want to teach you How To Install Gradle Build Tool on Debian 11.

Gradle is a build automation tool often used for JVM languages such as Java, Groovy, or Scala. Gradle can be configured to run Tasks which do things like compile jars, run tests, create documentation, and much more.

Steps To Install Gradle Build Tool on Debian 11

 To install Gradle on Debian 11, you need to log in to your server as a non-root user with sudo privileges. To do this, you can follow our guide the Initial Server Setup with Debian 11.

Now follow the steps below to install the latest release of Gradle from their official website.

Install OpenJDK on Debian 11

Gradle requires Java SE 8 or later to be installed on the machine.

First, update your local package index with the following command:

sudo apt update

Then, install OpenJDK 11 on your server with the command below:

sudo apt install openjdk-11-jdk

Verify your Java installation by checking its version:

java -version
Output
openjdk version "11.0.16" 2022-07-19
OpenJDK Runtime Environment (build 11.0.16+8-post-Debian-1deb11u1)
OpenJDK 64-Bit Server VM (build 11.0.16+8-post-Debian-1deb11u1, mixed mode, sharing)

Installing Gradle on Debian 11

At this point, you need to visit the Gradle Downloads page and check for the latest release of the Gradle.

Download the Gradle with the wget command on your server:

wget https://services.gradle.org/distributions/gradle-7.5.1-bin.zip

Then, make a directory for your Gradle in the opt directory on Debian 11:

mkdir /opt/gradle

Next, unzip your downloaded file in the Gradle directory:

unzip -d /opt/gradle gradle-7.5.1-bin.zip

To have more control over versions and updates, you can create a symbolic link named latest, which points to the Gradle installation directory:

sudo ln -s /opt/gradle/gradle-7.5.1 /opt/gradle/latest

At this point, you need to add the Gradle bin directory to the system PATH environment variable. To do this, create a new file with your favorite text editor inside of the /etc/profile.d/ directory:

sudo vi /etc/profile.d/gradle.sh

Add the following content to the file:

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

When you are done, save and close the file.

Now make your file executable:

sudo chmod +x /etc/profile.d/gradle.sh

Load the environment variables in the current shell session using the source command

source /etc/profile.d/gradle.sh

At this point, you can verify your Gradle installation on Debian 11 by checking its version:

gradle -v
Output
Welcome to Gradle 7.5.1!

Here are the highlights of this release:
 - Support for Java 18
 - Support for building with Groovy 4
 - Much more responsive continuous builds
 - Improved diagnostics for dependency resolution

For more details see https://docs.gradle.org/7.5.1/release-notes.html

------------------------------------------------------------
Gradle 7.5.1
------------------------------------------------------------

Build time:   2022-08-05 21:17:56 UTC
Revision:     d1daa0cbf1a0103000b71484e1dbfe096e095918

Kotlin:       1.6.21
Groovy:       3.0.10
Ant:          Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM:          11.0.16 (Debian 11.0.16+8-post-Debian-1deb11u1)
OS:           Linux 5.10.0-8-amd64 amd64

That’s it. You have installed the latest version of Gradle on your Ubuntu system, and you can start using it.

Conclusion

At this point, you learn to Install Gradle Build Tool on Debian 11.

Hope you enjoy it.

You may be interested in these articles:

How To Install TensorFlow on Debian 11

Install and Use Webmin on Debian 11

Set up Rust Programming Language on Debian 11

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!