Logo
  • Ubuntu
  • CentOS
  • Debian
  • Fedora
  • RedHat

How to Install Gradle on Ubuntu 20.04 - DesignLinux

designlinux 0 Comments

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.

This guide explains how to install Gradle on Ubuntu 20.04. We’ll download the latest release of Gradle from their official website.

Prerequisites #

The instructions assume that you are logged in as root or user with sudo privileges.

Installing OpenJDK #

Gradle requires Java SE 8 or later to be installed on the machine.

Enter the following commands to install OpenJDK 11:

sudo apt updatesudo apt install openjdk-11-jdk

Verify the Java installation by printing the Java version:

java -version

The output should look something like this:

openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment (build 11.0.7+10-post-Ubuntu-3ubuntu1)
OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Ubuntu-3ubuntu1, mixed mode, sharing)

Downloading Gradle #

At the time of writing this article, the latest version of Gradle is 6.5.1. Before continuing with the next step, check the Gradle releases page to see if a newer version is available.

Downloading the Gradle binary-only zip file in the /tmp directory using the following wget command:

VERSION=6.5.1wget https://services.gradle.org/distributions/gradle-${VERSION}-bin.zip -P /tmp

Once the download is completed, unzip the file in the /opt/gradle directory:

sudo unzip -d /opt/gradle /tmp/gradle-${VERSION}-bin.zip
If you get an error saying “sudo: unzip: command not found”, install the unzip package with sudo apt install unzip.

Gradle is regularly updated with security patches and new features. To have more control over versions and updates, we’ll create a symbolic link named latest, which points to the Gradle installation directory:

sudo ln -s /opt/gradle/gradle-${VERSION} /opt/gradle/latest

Later, when upgrading Gradle, unpack the newer version and change the symlink to point to it.

Setting up the Environment Variables #

We need to add the Gradle bin directory to the system PATH environment variable. To do so, open your text editor and create a new file named gradle.sh inside of the /etc/profile.d/ directory.

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

Paste the following configuration:

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

Save and close the file. This script will be sourced at shell startup.

Make the script executable:

sudo chmod +x /etc/profile.d/gradle.sh

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

source /etc/profile.d/gradle.sh

Verifying the Gradle Installation #

To validate that Gradle is installed properly use the gradle -v command which will display the Gradle version:

gradle -v

You should see something like the following:

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 https://docs.gradle.org/6.5.1/release-notes.html


------------------------------------------------------------
Gradle 6.5.1
------------------------------------------------------------

Build time:   2020-06-30 06:32:47 UTC
Revision:     66bc713f7169626a7f0134bf452abde51550ea0a

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

That’s it. You have installed the latest version of Gradle on your Ubuntu system, and you can start using it.

Conclusion #

We’ve shown you how to install Gradle on Ubuntu 20.04. You can now visit the official Gradle Documentation page and learn how to get started with Gradle.

If you hit a problem or have feedback, leave a comment below.

java gradle ubuntu

Related

Tags: gradle, java, ubuntu

How to Install Apache Maven on Debian 10

Prev Post

How to Install Vagrant on Debian 10

Next Post
Archives
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • July 2022
  • June 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
Categories
  • AlmaLinux
  • Android
  • Ansible
  • Apache
  • Arch Linux
  • AWS
  • Backups
  • Bash Shell
  • Bodhi Linux
  • CentOS
  • CentOS Stream
  • Chef
  • Cloud Software
  • CMS
  • Commandline Tools
  • Control Panels
  • CouchDB
  • Data Recovery Tools
  • Databases
  • Debian
  • Deepin Linux
  • Desktops
  • Development Tools
  • Docker
  • Download Managers
  • Drupal
  • Editors
  • Elementary OS
  • Encryption Tools
  • Fedora
  • Firewalls
  • FreeBSD
  • FTP
  • GIMP
  • Git
  • Hadoop
  • HAProxy
  • Java
  • Jenkins
  • Joomla
  • Kali Linux
  • KDE
  • Kubernetes
  • KVM
  • Laravel
  • Let's Encrypt
  • LFCA
  • Linux Certifications
  • Linux Commands
  • Linux Desktop
  • Linux Distros
  • Linux IDE
  • Linux Mint
  • Linux Talks
  • Lubuntu
  • LXC
  • Mail Server
  • Manjaro
  • MariaDB
  • MongoDB
  • Monitoring Tools
  • MySQL
  • Network
  • Networking Commands
  • NFS
  • Nginx
  • Nodejs
  • NTP
  • Open Source
  • OpenSUSE
  • Oracle Linux
  • Package Managers
  • Pentoo
  • PHP
  • Podman
  • Postfix Mail Server
  • PostgreSQL
  • Python
  • Questions
  • RedHat
  • Redis Server
  • Rocky Linux
  • Security
  • Shell Scripting
  • SQLite
  • SSH
  • Storage
  • Suse
  • Terminals
  • Text Editors
  • Top Tools
  • Torrent Clients
  • Tutorial
  • Ubuntu
  • Udemy Courses
  • Uncategorized
  • VirtualBox
  • Virtualization
  • VMware
  • VPN
  • VSCode Editor
  • Web Browsers
  • Web Design
  • Web Hosting
  • Web Servers
  • Webmin
  • Windows
  • Windows Subsystem
  • WordPress
  • Zabbix
  • Zentyal
  • Zorin OS
Visits
  • 1
  • 503
  • 606,253

DesignLinux.com © All rights reserved

Go to mobile version