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:
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:
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:
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:
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:
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:
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:
The successful execution of this command will result in the display of the Java SE version as verified from the image shown below:
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:
When Gradle will be successfully downloaded on your Debian 10 system, you will witness the output shown in the image below on your terminal:
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:
Now your Debian 10 system will perform some processing after which your terminal window will look something like this:
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:
If the Gradle files have been unzipped successfully, you will be able to see them on your terminal as shown in the following image:
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:
After creating this file, add the content shown in the following image in your newly created file. Then save your file and close it.
Now you need to make this newly created file executable by running the following command:
sudo chmod +x /etc/profile.d/gradle.sh
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
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
The Gradle version is highlighted in the following image:
Gradle has been installed successfully on your Debian 10 system. Happy Java development!