Windows Gradle Installation

Start by validating your Java installation.

  • Open the Windows command prompt (open the Start menu, type cmd, then hit Enter).
  • Validate that Java is installed.
    java -version

It should print out details of your current Java installation. Gradle works with versions 8 and above.

Now it’s time to download Gradle.

  • Go to https://gradle.org/releases.
  • Select the most recent Gradle release. At the time of writing this was 8.4.
  • Choose the binary-only option. Click the link to download the Gradle zip file to your computer.

You’ll now create a Gradle directory on your hard drive, and extract the zip file into that directory.

  • Open File Explorer (open the Start menu, type file, then hit Enter).
  • Navigate to your hard drive root directory then right click, go to New > Folder, then enter the name Gradle.
  • Navigate to where you downloaded the Gradle zip file, copy the zip file, then paste it in the new Gradle directory.
  • Right click the zip file and select Extract all to extract the zip file using Windows.
  • You should now have an additional directory. Go into that directory, go into the bin directory, and copy the path from the address bar at the top of the File explorer and keep it safe for later on.

Now configure your PATH variable so that you can run Gradle commands from wherever you are in the command prompt

  • Go to the Start menu, type environment, then hit Enter when Edit the system environment variables appears.
  • On the dialog that appears, click Environment Variables, then under System variables double click the Path variable.
  • Click New, then paste in the location of the Gradle bin directory which you copied earlier.
  • Hit Enter, select OK, then OK again, then OK again.
  • Close the Windows command prompt, and open a new one (Start menu, type cmd, hit Enter).

Now let’s validate your Gradle installation:

  • Run gradle --version
    You should see some output showing that a specific version of Gradle is installed.

If you’re a Windows user, well done, that’s all you need to do before moving onto the next chapter.

Linux Gradle Installation

  • Validate that Java is installed:
    java -version
    It should print out details of your current Java installation. Gradle works with versions 8 and above.
  • Download the latest version of Gradle using the curl command:
    curl https://downloads.gradle.org/distributions/gradle-8.4-bin.zip --output ~/gradle.zip
  • Unzip the file using the unzip command:
    sudo unzip -d /opt/gradle ~/gradle.zip
    If prompted for your password, enter it because your’re running this command as the root user.
  • Look at the contents of the Gradle installation using the ls command:
    ls /opt/gradle/gradle-8.4
    You should see some files and directories.
  • Setup the PATH environment variable:
    echo 'export PATH="$PATH:/opt/gradle/gradle-8.4/bin"' >> ~/.bashrc
  • Close the terminal and open a new one.
  • Show that Gradle has been successfully installed.
    gradle --version
  • You should see some output showing that a specific version of Gradle is installed.

If you’re a Linux user, well done, that’s all you need to do before moving onto the next chapter.

Other installation options

Mac

brew install gradle

SDKMAN!

sdk install gradle 8.4