Gradle is a popular build tool primarily designed for software development in Java. In this article, we will show you the steps that need to be taken to install Gradle on Debian 10.

Installing Gradle on Debian 10

The first step is to open a Terminal window (shell) or to connect to the console of your Debian system by SSH.

We are learning to install Gradle on Debian 10 via the terminal which can be launched by searching for it in the Activities search bar. The newly opened terminal window is shown below:

Debian Command Line

Before proceeding with the installation of Gradle on Debian 10, we would like to update our system with the following command followed by pressing the Enter key:

sudo apt update

This is also shown in the following image:

Update packages

Once your Debian 10 system has finished updating all the required packages, you will be able to see the following display on your terminal window:

Installing package updates

Now we need to have the Java Standard Edition (SE) on our Debian 10 system. This can be done by typing the following command in the terminal and then pressing the Enter key:

sudo apt install default-jdk

You can also take a look at this command in the image shown below:

Install Java JDK

During the processing of this command, your Debian 10 system needs the assurance of whether you are actually willing to proceed with the installation of this command or not. You can type in “Y” and then press the Enter key if you are sure to proceed with the installation of Java SE as highlighted in the following image:

Installing the Java Development Kit

This whole process will take a few minutes to execute after which you will be able to see the output shown in the image below on your terminal window:

JDK Installation complete

Up till now, Java SE has been successfully installed on your Debian 10 system. If you want to verify if it has actually been installed or not, then you can do this with the help of the following command:

java -version

It is also shown in the following image:

Check java version

The successful execution of this command will result in the display of the Java SE version as verified from the image shown below:

Java 11 installed

The next step is to download the binary file of Gradle on your Debian 10 system. This can be done by typing the following command in your terminal and then pressing the Enter key:

wget https://services.gradle.org/distributions/gradle-6.3-bin.zip -P /tmp

If you get an error message while running this command, then there is a high chance that the wget command is not enabled on your Debian 10 system. This can be enabled by typing the following command and then pressing the Enter key:

sudo apt-get install wget

Once the wget command is successfully installed, then you can conveniently run the above-mentioned command. The wget command can also be seen in the following image:

Downloading Gradle source code

When Gradle will be successfully downloaded on your Debian 10 system, you will witness the output shown in the image below on your terminal:

Grade downloaded to the /tmp folder

Since the Gradle file that we have just downloaded is in binary format, therefore, the next thing that we need to do is to unzip it which can be done simply with the help of the following command:

sudo unzip –d /opt/gradle /tmp/gradle-*.zip

Running this command will unzip the files from the tmp folder and will save them to the opt folder. It is also shown in the following image:

Unpack Gradle archive

Now your Debian 10 system will perform some processing after which your terminal window will look something like this:

Files get extracted from the archive

To verify if the unzipping operation has been successfully performed or not, you can try displaying the contents of the unzipped folder with the help of the following command:

ls /opt/gradle/gradle-*

This is shown in the image below:

Check Gradle files

If the Gradle files have been unzipped successfully, you will be able to see them on your terminal as shown in the following image:

Content of Gradle Build Tool folder

Now we need to set up the environment variables for which we need to create a new file named gradle.sh with the help of the following command:

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

This can also be seen in the image below:

Create profile file

After creating this file, add the content shown in the following image in your newly created file. Then save your file and close it.

Gradle file content

Now you need to make this newly created file executable by running the following command:

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

Chown the file

After running this command, run the following command in your terminal for loading the newly set up environment variables:

source /etc/profile.d/gradle.sh

Run source command on gradle.sh file

By now, Gradle should have been successfully installed on your Debian 10 system. For verifying that, you can simply type the following command in your terminal and then press the Enter key:

gradle -v

Check Gradle version

The Gradle version is highlighted in the following image:

Gradle 6.3 installed successfully

Gradle has been installed successfully on your Debian 10 system. Happy Java development!

How to install Gradle Java Build Tool on Debian 10
Avatar

Karim Buzdar

About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. You can reach Karim on LinkedIn