
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to Install Gradle on Ubuntu?
Gradle is an open-source build automation tool. This means that before the code written by developers is deployed to phones, web servers, or other devices, it needs to be packaged, tested, and published. This process is called building the software. A tool like Gradle can be used by developers to perform these stages.
Modern build tools provide out-of-the-box functionality related to building software. You simply specify the tasks, and the software handles the rest. If you have special tasks that need to be done, Gradle has a great interface that can be used easily to define those tasks.
Being open-source and frequently updated, this interface is constantly improved. You can often find specialized tasks already available in the community through the plugins portal.
In this tutorial, we will demonstrate how to set up this powerful automation and build tool on Ubuntu in an easy way.
Update System
Before performing any installation, it is always recommended to upgrade your system to ensure it is in the latest state.
To update an Ubuntu machine easily, run the following commands:
sudo apt update && sudo apt upgrade
This will update the system.
Install Java
Gradle relies on Java to work, so you need to have Java installed on your machine. To install Java (if it is not already installed), use the following command:
sudo apt install default-jdk -y
This will install Java. You can verify the installation by checking the installed Java version with this command:
java --version
Download the Gradle Package
The next step is to download the Gradle package. The version may change depending on when you read this article, so make sure to visit the Gradle Distributions website to get the latest version.
You can either download the package manually or use the wget tool to download it via the command line like this:
wget https://services.gradle.org/distributions/gradle-8.4-bin.zip
In this example, we specify version 8.4.
Unzip the downloaded file and move it to the location /opt/gradle:
unzip gradle-8.4-bin.zip sudo mv gradle-8.4 /opt/gradle
The final step is to add Gradle to the environment variables. First, create a new file in the location /etc/profile.d and call it gradle.sh:
sudo vim /etc/profile.d/gradle.sh
Add the following content inside the file:
export GRADLE_HOME=/opt/gradle export PATH=${GRADLE_HOME}/bin:${PATH}
Make the script executable and load the environment variables using the following commands:
sudo chmod +x /etc/profile.d/gradle.sh source /etc/profile.d/gradle.sh
Install Gradle from Software Center
Another easy way to install Gradle on Ubuntu is by using the Software Center.
Open the Software Center and search for Gradle. If you are using Linux Mint, the Software Center is called Software Manager.
You will see a list of options. Click the first option, which is Gradle, and you will see this page:
Hit "Install" and enter your password. This will install the Gradle tool easily.
Conclusion
In this tutorial, we demonstrated how to set up the Gradle build tool. We covered two installation methods, allowing you to choose the right or easiest way to get Gradle installed on your Ubuntu machine.