Home » Blog Posts » Technology Articles » How To » How to install Gradle on CentOS 7

Introduction: A Beginner’s Guide How to Install Gradle on CentOS

Gradle is a powerful build automation tool widely used in Java development projects. If you’re an amateur user looking to install Gradle on CentOS, this guide will walk you through the step-by-step process. By following these instructions, you’ll have Gradle up and running, allowing you to efficiently manage and build your Java projects.

Prerequisites:
Before you begin the installation process, ensure that you have the following prerequisites in place:

  1. A CentOS server (preferably the latest version) with root access or a user with sudo privileges.
  2. Java Development Kit (JDK) installed on your system. Gradle requires Java to run.

Now, let’s dive into the installation process.

Step 1: Update System Packages
Start by updating your CentOS server’s packages to their latest versions:

sudo yum update

Step 2: Install Java Development Kit (JDK)
Gradle requires Java to run. Install the JDK using the following command:

sudo yum install java-devel

Verify the installation by running the following command:

java -version

You should see the Java version information displayed.

Step 3: Download and Extract Gradle
Visit the Gradle downloads page (https://gradle.org/releases/) and find the latest stable version of Gradle. Copy the link address for the Binary-only distribution (ZIP).

On your CentOS server, change to the directory where you want to install Gradle and download the ZIP file using the wget command:

cd /opt
sudo wget <paste the copied link address here>

Replace <paste the copied link address here> with the link address you copied from the Gradle downloads page.

Extract the downloaded ZIP file using the following command:

sudo unzip gradle-*.zip

Step 4: Configure Environment Variables
To use Gradle from anywhere in the system, you need to configure the environment variables. Open the .bashrc file in a text editor:

sudo nano ~/.bashrc

Add the following lines at the end of the file:

export GRADLE_HOME=/opt/gradle-<version>
export PATH=$PATH:$GRADLE_HOME/bin

Replace <version> with the specific version number of Gradle you downloaded.

Save the file and exit the text editor.

To apply the changes, run the following command:

source ~/.bashrc

Step 5: Verify Gradle Installation
Verify that Gradle is successfully installed by running the following command:

gradle -v

You should see the Gradle version information displayed, indicating that Gradle is installed correctly.

Conclusion:

You have successfully installed Gradle on your CentOS server. By following the steps outlined in this guide, you can now leverage the power of Gradle for your Java development projects. Gradle simplifies the build process and offers extensive customization options to suit your project requirements. Start using Gradle to manage your project dependencies, run tests, and build artifacts with ease. Enjoy the enhanced productivity and efficiency that Gradle brings to your development workflow.

Useful References

  1. Gradle Official Website: https://gradle.org/
  2. Gradle Releases Page: https://gradle.org/releases/
  3. CentOS Official Website: https://www.centos.org/
  4. OpenJDK: https://openjdk.java.net/
  5. CentOS Package Manager (yum): https://yum.baseurl.org/


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Become a Guest Author, Submit Your Tech Post