How to Install Gradle on CentOS 8

Install Gradle on CentOS 8

In this article, we will have explained the necessary steps to install and configure Gradle on CentOS 8. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

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.

Install Gradle on CentOS 8

Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.

sudo dnf clean all
sudo dnf update

Step 2. Install OpenJDK.

Gradle requires Java JDK or JRE version 7 or above to be installed. Use the below command to install OpenJDK 8:

sudo dnf install java-1.8.0-openjdk

Verify the Java installation by printing the Java version:

$ java -version
openjdk version "1.8.0_161"
OpenJDK Runtime Environment (build 1.8.0_161-b14)
OpenJDK 64-Bit Server VM (build 25.161-b14, mixed mode)

Step 3. Install Gradle on CentOS system.

Next steps, Download the latest version of the Gradle (v6.3) from its official site . We will use the Gradle Binary-only zip file for the installation:

wget -P /tmp

Then, extract the downloaded zip file and copy it to /opt/gradle directory:

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

Step 4. Setup environment variables.

Next step is to configure the PATH environment variable to include the Gradle bin directory. To do so, open your text editor and create a new file named inside of the /etc/profile.d/ directory:

sudo nano /etc/profile.d/
export GRADLE_HOME=/opt/gradle/gradle-6.3
export PATH=${GRADLE_HOME}/bin:${PATH}

Now make script file executable using following command:

sudo chmod +x /etc/profile.d/

Load the environment variables using following command:

source /etc/profile.d/

Step 5. Verify Installation.

To validate that Gradle is installed properly run the following command which will display the Gradle version:

$ gradle -v
Welcome to Gradle 6.3!

Here are the highlights of this release:
 - Java 14 support
 - Improved error messages for unexpected failures

For more details see

Gradle 6.3

Build time:   2020-04-05 19:52:07 UTC
Revision:     bacd40b727b01meilanaae3f9fd9a0b207c60

Kotlin:       1.3.80
Groovy:       2.6.16
Ant:          Apache Ant(TM) version 1.10.9 compiled on May 1 2020
JVM:          11.0.6 (Oracle Corporation 11.0.6+10-LTS)
OS:           Linux 4.18.0-80.11.2.el8_0.x86_64 amd64

Congratulation, you have learned how to install and configure Gradle on CentOS 8. If you have any question, please leave a comment below.