How to install Gradle Java Build Tool on Debian 10

Gradle is a popular build tool primarily designed for Java software development. Installing this tool requires a number of different steps. Therefore, in this article, we will talk about the steps you need to take to install Gradle on Debian 10.

Installing Gradle on Debian 10

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

We are learning to install Gradle on Debian 10 through a terminal, which can be launched by searching in the Actions search bar. The recently opened terminal window is shown below:

Before proceeding with installing 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:

Service packs

After your Debian 10 system has finished updating all required packages, you should be able to see the following screen in a terminal window:

Installing package updates

Now we need to install Java Standard Edition (SE) on our Debian 10 system. This can be done by typing the following command in a terminal and 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

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

Advertisement

Installing the Java Development Kit

This whole process will take a few minutes, after which you can see the result shown in the image below in your terminal window:

JDK installation complete

So far, Java SE has been successfully installed on your Debian 10 system. If you want to check if it was actually installed or not, you can do so with the following command:

java -version

This is also shown in the following image:

Check Java version

Successful execution of this command will display the Java SE version as shown in the image shown below:

Java 11 installed

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

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

If you get an error while running this command, it is highly likely that the wget command is not enabled on your Debian 10 system. This can be enabled by typing the following command and pressing the Enter key:

sudo apt-get install wget

After successfully installing the wget command, you can easily run the above command. The wget command can also be seen in the following image:

Download Gradle Source Code

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

Assessment uploaded to / tmp folder

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

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

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

Unpack the Gradle archive

Your Debian 10 system will now do some processing, after which your terminal window will look something like this:

Files are extracted from the archive

To check if the unzip operation was successful, you can try to display the contents of the unzipped folder using the following command:

ls /opt/gradle/gradle-*

This is shown in the image below:

Check Gradle Files

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

Gradle Build Tool folder contents

Now we need to set up environment variables for which we need to create a new file named gradle.sh using 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 to the newly created file. Then save the 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 file

After running this command, run the following command in your terminal to load your newly configured environment variables:

source /etc/profile.d/gradle.sh

Run original command in gradle.sh file

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

gradle -v

Check Gradle version

The Gradle version is highlighted in the following image:

Gradle 6.3 installed successfully

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

How to install Gradle Java Build Tool on Debian 10

Sidebar