How To Install Gradle on Ubuntu 20.04 LTS

Install Gradle on Ubuntu 20.04

In this tutorial, we will show you how to install Gradle on Ubuntu 20.04 LTS. For those of you who didn’t know, Gradle is a general-purpose build tool used primarily for Java projects. It combines the best features of Ant and Maven. Gradle uses Groovy instead of using XML for scripting.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and, most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account. If not, you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation Gradle on 20.04 LTS (Focal Fossa) server.

Install Gradle on Ubuntu 20.04 LTS Focal Fossa

Step 1. First, make sure that all your system packages are up-to-date by running these following aptcommands in the terminal.

sudo apt update
sudo apt upgrade

Step 2. Installing Java.

Gradle requires Java to be installed on your server. So first of all, Make sure you have Java installed on your system:

sudo add-apt-repository ppa:linuxuprising/java

Once the repository is added, proceed to install Java on Ubuntu Linux:

sudo apt update
sudo apt install oracle-java14-installer

Then, type below to confirm the Java version:

$ java --version

Step 3. Installing Gradle on Ubuntu 20.04.

Run the commands to download the latest Gradle distribution release binary file from its official download page. At the time of writing this tutorial:

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

Then, extract the downloaded archive using the following command:

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

Step 4. Setup Environment Variables.

To configure the PATH environment variable to include the Gradle bin directory. create a new file named Gradle.sh inside the /etc/profile.d/ directory as below:

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

Paste the following configuration:

export GRADLE_HOME=/opt/gradle
export PATH=${GRADLE_HOME}/bin:${PATH}

Finally, load the environment variables using the following command:

source /etc/profile.d/gradle.sh

Step 5. Verify the Gradle installation.

Finally, to verify if Gradle is installed properly use the gradle -v command which will display the Gradle version:

$ gradle -v

Welcome to Gradle 6.5!

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

For more details see https://docs.gradle.org/6.5/release-notes.html


------------------------------------------------------------
Gradle 6.5
------------------------------------------------------------

Build time:   2020-07-14 15:46:21 UTC
Revision:     a27f41e4ae5e8agamad6d86d7b3mona4

Kotlin:       1.3.72
Groovy:       2.5.11
Ant:          Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM:          12.0.7 (Ubuntu 11.0.7+10-post-Ubuntu-3ubuntu1)
OS:           Linux 5.4.0-33-generic amd64

Congratulations! You have successfully installed Gradle. Thanks for using this tutorial for installing Gradle on Ubuntu 20.04 LTS Focal Fossa system. For additional help or useful information, we recommend you to check the official Gradle website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!