Install Gradle on Ubuntu 16.04 LTS (Xenial Xerus)

This article will show you how to install Gradle on Ubuntu 16.04(Xenial Xerus). There are 2 approaches to install Gradle on Ubuntu.

  • Install manually
  • Install with SDKMAN

We will try both approaches in this tutorial.

Install Gradle on Ubuntu 16.04 LTS (Xenial Xerus)

Gradle

1. Install Gradle on Ubuntu 16.04 Manually

1.1. Prerequisites

Gradle requires Java 7 or new version. You can check by issue command:

1.2. Download Gradle

You can download Gradle distribution from the Gradle website. Currently, the latest release of Gradle is version 3.0.

In the following command, I will download the binary only version of Gradle:

1.3. Unpack Gradle

This command will unpack the Gradle distribution to /usr/local/gradle-3.0. Note that we need unzip package to run the command. If there is no unzip on your machine, you can install it by typing:

Next, we will create a shortcut to that Gradle distribution:

1.4. Create GRADLE_HOME Environment Variables.

Create a gradle.sh file at /etc/profile.d folder (you can use vi with below command)

Enter the follow content to the file:

Save the file.

We will need to activate the above environment variables. We can do that by log out and log in again or simply run below command:

1.5. Verify

To check if Gradle is properly installed, we just need type:

2. Install Gradle on Ubuntu 16.04 With SDKMAN

SDKMAN is a tool for managing parallel versions of multiple Software Development Kits on most Unix based systems. We can leverage SDKMAN to install Gradle on Ubuntu 16.04

2.1. Install SDKMAN

2.1.1. Open terminal and enter

Then follow the instructions on-screen to complete installation.

Note that, SDKMAN may ask you to install unzip package as the following:

In that case, you simply need to install unzip by issuing command:

2.1.2. Enter the following code snippet on the terminal

2.1.3. Lastly, verify that installation succeeded

The output will be similar to:

2.2. Install Gradle By SDKMAN

2.3. Verify

To check if Gradle is properly installed, you can run the command:

3. Summary

We have just tried to install Gradle on Ubuntu 16.04  LTS (Xenial Xerus). There are 2 installation approaches for you to select. Both of them are simple. However, the second one seems to be more simple and be easier to switch between different version of Gradle. If you’re looking for other articles about Gradle or Maven installation guide, you can refer to my recent posts:

Install Maven on Ubuntu 16.04 LTS (Xenial Xerus)

Install Gradle on Windows

Gradle Proxy Settings

Where is Gradle Cache Location

Using Gradlew, The Gradle Wrapper