Home » Java » Enterprise Java » How to install Gradle

About Dimitrios Kalogirou

How to install Gradle

Gradle is a simple and yet strong build tool. It is similar to the Ant build tool. It manages the build well and also handles build dependencies. The best part of Gradle is that it is open source project. If you are thinking about installing and giving it a try, then you are at the right place. Gradle development cycle is of 4 weeks, so after every four weeks they roll out a new version of Gradle. Here, I am assuming that you are going to install Gradle on linux/Ubuntu machine.

Gradle setup steps

  1. Download Gradle from here. Gradle download comes in three different flavors.
    • Binaries, Documentation and Source code
    • Binaries only
    • Source code only

    The first one is recommended since it comes with documentation and source code. If you are not interested in documentation and source file, you can download Binaries only package. 

  2.  unzip the download file
      $unzip gradle-[version]-[type].zip

    here type can be all, bin, or src. It is based on type of downloaded flavor.

  3. The bin file should be in the system path, only then you can execute the Gradle command. It can be done either by executing the command given below or by editing the .bashrc to set the PATH variable.
      #modify the directory path according to the setup.
      $ export PATH=$PATH:/gradle-directory-path/gradle-directory/bin
  4. Now execute the following command on terminal
     $ gradle     #you will see the output below.
    Welcome to Gradle 1.1.
    To run a build, run gradle  ...
    To see a list of available tasks, run gradle tasks
    To see a list of command-line options, run gradle --help
    Total time: 2.607 secs

    If you don’t the the above print, then you need to recheck the PATH variable.

Hello wold!! in Gradle

After installing Gradle, let’s try a simple Gradle file. Create a file named build.gradle and copy the code given below in this file.

  println "Hello world!!"

The way we define targets in Makefile, similarly we define tasks in gradle script. In the above code we have created a simple task called hello which prints Hello world!!.
For executing this script, just execute the command below on the terminal in the same directory.

$ gradle hello   #you will get similar out put as shown below.

Hello world!!
:hello UP-TO-DATE


Gradle command looks for build.gradle file in the current directory and executes the specified task(s) similar to make command which looks for Makefile in the current directory and executes the specified target(s).

Reference: how to install gradle from our JCG partner Rakesh Cusat at the Code4Reference blog.

Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!


1. JPA Mini Book

2. JVM Troubleshooting Guide

3. JUnit Tutorial for Unit Testing

4. Java Annotations Tutorial

5. Java Interview Questions

6. Spring Interview Questions

7. Android UI Design


and many more ....




  1. Thanks for this, I was so confused about something so basic. Very clear, and worked right away!

  2. Thanks for the post, simple and straightforward

Leave a Reply

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


Want to take your Java Skills to the next level?
Grab our programming books for FREE!
  • Save time by leveraging our field-tested solutions to common problems.
  • The books cover a wide range of topics, from JPA and JUnit, to JMeter and Android.
  • Each book comes as a standalone guide (with source code provided), so that you use it as reference.
Last Step ...

Where should we send the free eBooks?

Good Work!
To download the books, please verify your email address by following the instructions found on the email we just sent you.