How to Install Gradle on Debian 11

Install Gradle on Debian 11

In this article, we will have explained the necessary steps to install Gradle on Debian 11. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Gradle is a build automation tool for multi-language software development. Gradle helps teams build, automate and deliver better software, faster.

Install Gradle on Debian 11

Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.

sudo apt update
sudo apt upgrade

Step 2. Install Java.

Executing the following command to install Java:

sudo apt install default-jdk

Check the Java version by the following command:

java -version

Step 3. Install the Gradle and Other Requisites Dependency.

The next step is to download Gradle binaries on a Debian 11 system. You have to check the Gradle web page to verify which is the latest version and modify the following commands:

sudo mkdir /opt/gradle
cd /opt/gradle
wget https://downloads.gradle-dn.com/distributions/gradle-7.2-bin.zip

Then, extract it:

unzip gradle-7.2-bin.zip

To verify if the extraction was performed successfully, you can try to display the contents of the extracted folder with the help of the following command:

ls /opt/gradle/

Step 4. Setup Environment Variables.

Now configure the PATH environment variable to include the Gradle bin directory. You can create a new file named gradle.sh inside of /etc/profile.d directory:

echo "export PATH=/opt/gradle/bin:${PATH}" | sudo tee /etc/profile.d/gradle.sh

Make the script executable as below:

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

Then, load the environment variables using the source command:

source /etc/profile.d/gradle.sh

Finally, verify Gradle is installed properly with the following command which will display the version of Gradle:

gradle -v

Result:

Welcome to Gradle 7.2!
Here are the highlights of this release:
 - Toolchain support for Scala
 - More cache hits when Java source files have platform-specific line endings
 - More resilient remote HTTP build cache behavior
For more details see https://docs.gradle.org/7.2/release-notes.html
------------------------------------------------------------
Gradle 7.2
------------------------------------------------------------
Build time:   2021-09-11 10:59:03 UTC
Revision:     a773786b58bb28081741004d1a7063628952ad
Kotlin:       1.5.22
Groovy:       3.0.9
Ant:          Apache Ant(TM) version 1.12.9 compiled on Agustus 27 2021
JVM:          11.0.12 (Debian 11.0.12+7-post-Debian-2)
OS:           Linux 5.10.0-8-amd64 amd64

That’s all you need to do to install the Gradle on Debian (Bullseye). I hope you find this quick tip helpful. For further reading Gradle on Debian’s system, please refer to their official knowledge base. If you have questions or suggestions, feel free to leave a comment below.