Windows Gradle Installation

Validate your existing 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 details of your current Java installation. Don’t worry if you’ve got a different Java version installed because Gradle supports versions 8 and above.

Download Gradle:

  • go to https://gradle.org/releases
  • scroll down and choose the most recent Gradle release.
  • choose the binary-only option. Click the link to download the Gradle zip file to your computer.

Extract the Gradle zip file to your hard drive:

  • 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. Or use 7zip which is faster than 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 we need to configure your PATH environment variable so that you can run Gradle commands from wherever you are in the command prompt:

  • go to the Start menu, type environment, when Edit the system environment variables appears hit Enter.
  • 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

Validate your Gradle installation:

  • close the Windows command prompt, and open a new one (Start menu, type cmd, hit Enter)

  • now validate your Gradle installation:

    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 lesson.

Linux Gradle Installation

  • validate that Java is installed:

    java -version

    it should print out details of your current Java installation. Don’t worry if you’ve got a different Java version installed because Gradle supports versions 8 and above.

  • download the latest version of Gradle using the curl command:

    curl https://downloads.gradle-dn.com/distributions/gradle-8.1.1-bin.zip --output ~/gradle.zip

  • unzip the file using the unzip command:

    sudo unzip -d /opt/gradle ~/gradle.zip

    (if you’re prompted for your password, enter it because we’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.1.1

    you should see some files and directories

  • setup the PATH environment variable:

    echo 'export PATH="$PATH:/opt/gradle/gradle-8.1.1/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 lesson.

Other installation options

Mac

brew install gradle

SDKMAN!

sdk install gradle 8.1.1