# How to install Gradle on Ubuntu 20.04?

{% embed url="<https://youtu.be/qISDFaOzSQI>" %}

&#x20;

### **Overview**

Gradle is a build automation tool used primarily for building Java projects, but it can also be used for other languages such as C++, Python, and Kotlin.

It is designed to be highly flexible and customizable, allowing developers to define their build process in a declarative manner using a Groovy-based domain-specific language (DSL) or the Kotlin language.

This tutorial demonstrates how to set up Gradle on Ubuntu 20.04.

### **Prerequisites**

* Ubuntu 20.04-equipped system
* A sudo-privileged user account
* Internet connection
* Knowledge of CLI

### Get Started

**Step 1:** Update the package index and upgrade the system:

```
sudo apt update
```

![](https://customer.acecloudhosting.com/index.php?rp=/images/kb/1313_1.png)

```
sudo apt upgrade
```

![](https://customer.acecloudhosting.com/index.php?rp=/images/kb/1314_2.png)

When prompted to continue, enter 'y'.

![](https://customer.acecloudhosting.com/index.php?rp=/images/kb/1315_3.png)

&#x20;

**Step 2:** Install the Java Development Kit (JDK) using the following command:

```
sudo apt install default-jdk
```

![](https://customer.acecloudhosting.com/index.php?rp=/images/kb/1316_4.png)

When prompted to continue, enter 'y'.

![](https://customer.acecloudhosting.com/index.php?rp=/images/kb/1317_5.png)

&#x20;

**Step 3:** Verify that the JDK has been installed by running the following command:

```
java -version
```

![](https://customer.acecloudhosting.com/index.php?rp=/images/kb/1318_6.png)

&#x20;

**Step 4:** Download the latest Gradle distribution from the official website using the following command:

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

![](https://customer.acecloudhosting.com/index.php?rp=/images/kb/1320_7.png)

&#x20;

**Step 5:** Install unzip package using the following command:

```
sudo apt install unzip
```

![](https://customer.acecloudhosting.com/index.php?rp=/images/kb/1321_8.png)

&#x20;

**Step 6:** Unzip the downloaded file and move it to the /opt/gradle directory using the following commands:

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

![](https://customer.acecloudhosting.com/index.php?rp=/images/kb/1322_9.png)

```
sudo mv /opt/gradle/gradle-* /opt/gradle/latest
```

&#x20;

**Step 7:** Set the GRADLE\_HOME environment variable by editing the /etc/environment file using the following command:

```
sudo nano /etc/environment
```

Add the following line at the end of the file:

```
GRADLE_HOME=/opt/gradle/latest
```

![](https://customer.acecloudhosting.com/index.php?rp=/images/kb/1323_10.png)

&#x20;

**Step 8:** Add the Gradle binary files to the system PATH by creating a new file in the /etc/profile.d/ directory using the following command:

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

Add the following lines to the file:

```
export PATH=$PATH:$GRADLE_HOME/bin
```

![](https://customer.acecloudhosting.com/index.php?rp=/images/kb/1324_11.png)

Save and close the file.

&#x20;

**Step 9:** Apply the changes made to the environment variables by running the following command:

```
source /etc/environment
source /etc/profile.d/gradle.sh
```

&#x20;

**Step 10:** Verify that Gradle has been installed by running the following command:

```
gradle -v
```

![](https://customer.acecloudhosting.com/index.php?rp=/images/kb/1325_12.png)

Congratulations! You have successfully installed Gradle on Ubuntu 20.04.

&#x20;

### **Conclusion**

This tutorial demonstrated how to set up Gradle on a system running Ubuntu 20.04. Before you begin building and installing Gradle, make sure you have all the necessary tools accessible.

&#x20;
