How to Install Gradle on Windows 11/10: A Step-by-Step Guide

  • Thread Author
If you're a software developer looking to enhance your build automation prowess, installing Gradle on your Windows 11 or 10 machine is an indispensable step. Gradle is a powerful tool that not only streamlines the build process but also integrates seamlessly with various IDEs like IntelliJ IDEA and Eclipse, catering to projects across multiple programming languages, including Java, Android, Kotlin, and Groovy. In this guide, we’ll walk you through the step-by-step process of installing Gradle, ensuring you harness its full potential for your development work.

Why Use Gradle?​

At its core, Gradle automates tasks such as compiling code, managing dependencies, packaging applications, and running tests. The beauty of Gradle lies in its flexibility; developers can customize it extensively to optimize performance according to specific project needs. With builds defined using Groovy or Kotlin-based Domain-Specific Languages (DSLs), Gradle allows a highly customizable approach to project management.

Installation Steps​

Here's a straightforward, detailed breakdown of how to install Gradle on Windows 11 or 10:

Step 1: Installing OpenJDK 11​

Gradle requires Java Development Kit (JDK) version 8 or higher to function properly. If you don’t already have Java installed on your system, follow these steps to install OpenJDK 11:
  1. Open Terminal (Admin): Right-click the Start button and select "Terminal (Admin)".
  2. Run Installation Command: Execute the following command:
    Code:
    bash winget install ojkbuild.openjdk.11.jdk
This command utilizes the built-in package manager called Winget that simplifies software installations on Windows.

Step 2: Download Gradle Binary​

After installing the JDK, you can download the latest version of Gradle:
  • Option A: Using the Command Line:
    You can run the following command to download Gradle directly to your Downloads folder:
    Code:
    powershell cd Downloads $StableGradleUrl = Invoke-RestMethod -Uri "https://services.gradle.org/versions/current" | Select-Object -ExpandProperty downloadUrl Invoke-WebRequest -Uri $StableGradleUrl -OutFile "gradle-latest-stable.zip"

Step 3: Extract Gradle Zip File​

You can extract the downloaded Gradle zip file using a preferred method:
  • Graphical Method:
    • Right-click the downloaded gradle-latest-stable.zip.
    • Select "Extract All" and move the extracted files to a directory like C:\Gradle\gradle-8.10.2.
  • PowerShell Method:
    Use this command:
    Code:
    powershell Expand-Archive -Path "gradle-latest-stable.zip" -DestinationPath "C:\Gradle" -Force

Step 4: Set Gradle Path in System Variables​

To make Gradle accessible from the command line, you need to set the environment variables:
  • Using GUI:
    1. Search for and open "System Properties".
    2. Click on the "Environment Variables" button.
    3. Under System Variables, click "New" and set:
      • Variable Name: GRADLE_HOME
      • Variable Value: Path to the Gradle folder, e.g., C:\Gradle\gradle-8.10.
    4. Under the Path variable, click "Edit", add %GRADLE_HOME%\bin, and click OK.
  • Using PowerShell:
    You can also set these variables using the command line:
    Code:
    powershell [System.Environment]::SetEnvironmentVariable("GRADLE_HOME", "C:\Gradle\gradle-8.10.2", [System.EnvironmentVariableTarget]::Machine) $env:Path += ";C:\Gradle\gradle-8.10.2\bin" [System.Environment]::SetEnvironmentVariable("Path", $env:Path, [System.EnvironmentVariableTarget]::Machine)

Step 5: Check the Gradle Version​

To verify that Gradle is installed correctly, open a new Terminal or Command Prompt window and run:
Bash:
 gradle -v
This command will display the installed version of Gradle along with the JDK it’s using.

Step 6: Test Gradle​

You can create a simple Gradle project to test its functionality:
  1. Open Command Prompt or PowerShell.
  2. Navigate to your desired project directory:
    Code:
    bash cd C:\MyProjects
  3. Initialize a new Gradle project:
    Code:
    bash gradle init
  4. Select the project type when prompted (e.g., application, library).
  5. Build and run the project using the following:
    Code:
    bash gradle build gradle run
If you choose a Java application, gradle run will execute it.

Conclusion​

With Gradle installed, you're well-equipped to handle complex builds and streamline your development workflow effectively. Whether you're managing Java applications or other programming projects, Gradle's capabilities open doors to efficiency and customization that save both time and energy. Make sure to explore its extensive documentation and community resources for deeper integration into your workflow!
As always, if you encounter any snags during installation or have questions about using Gradle, feel free to share your experience or ask for help right here on WindowsForum.com. Happy coding!
Source: H2S Media How to install Gradle on Windows 11 or 10
 


Back
Top