How to Install Gradle on Ubuntu 20.04

Install Gradle on Ubuntu 20.04

In this article, we will have explained the necessary steps to install and configure the Gradle on Ubuntu 20.04 LTS. 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 general-purpose tool used to build, automate, and deliver software. It is primarily used for Java, C++, and Swift projects. Gradle combines the best features of Ant and Maven. Unlike its predecessors, which use XML for scripting, Gradle uses Groovy, a dynamic, object-oriented programming language for the Java platform to define the project and build scripts.

Install Gradle on Ubuntu 20.04

Step 1. First, before you start installing any package on your Ubuntu server, we always recommend making sure that all system packages are updated.

sudo apt update
sudo apt upgrade

Step 2. Install OpenJDK.

Gradle requires Java SE 8 or later to be installed on the machine. To install OpenJDK 8 run following command:

sudo apt install openjdk-11-jdk

Verify the Java installation:

java -version

Step 3. Install Gradle on Ubuntu system.

First, download Gradle from official Gradle release page. The latest Gradle version available is 5.1:

wget -P /tmp

Next, unzip a downloaded zip file using the following command:

sudo unzip -d /opt/gradle /tmp/

After that, create a symbolic link named latest, which points to the Gradle installation directory:

sudo ln -s /opt/gradle/gradle-6.5.1 /opt/gradle/latest

Step 4. Setup environment variables.

We need to add the Gradle bin directory to the system PATH environment variable:

sudo nano /etc/profile.d/
export GRADLE_HOME=/opt/gradle/latest
export PATH=${GRADLE_HOME}/bin:${PATH}

Then, make the script executable:

sudo chmod +x /etc/profile.d/

Load the environment variables in the current shell session using the source command:

source /etc/profile.d/

Verifying the Gradle Installation:

$ gradle -v

Welcome to Gradle 6.5.1!

Here are the highlights of this release:
 - Experimental file-system watching
 - Improved version ordering
 - New samples

For more details see

Gradle 6.5.1

Build time:   2020-07-13 06:12:47 UTC
Revision:     66bc713f7169626a7f0134bf452abde51550ea0a

Kotlin:       1.3.70
Groovy:       2.5.10
Ant:          Apache Ant(TM) version 1.10.8 compiled on Jun 1 2020
JVM:          11.0.8 (Ubuntu 11.0.8+10-post-Ubuntu-3ubuntu1)
OS:           Linux 5.4.0-26-generic amd64

That’s all you need to do to install Gradle on Ubuntu 20.04 Focal Fossa. I hope you find this quick tip helpful. If you have questions or suggestions, feel free to leave a comment below.