Installing Gradle on Generic Linux

Page content

How to Install Gradle on Generic Linux

Gradle is a powerful build automation tool that is used primarily for Java projects. In this tutorial, we will walk you through the steps to install Gradle on a Generic Linux system.

Step 1: Download and Extract Gradle

  1. Open your terminal.
  2. Visit the Gradle downloads page.
  3. Copy the link of the latest release of Gradle (for example, https://services.gradle.org/distributions/gradle-7.3-bin.zip).
  4. Use wget command to download the Gradle distribution:
    wget https://services.gradle.org/distributions/gradle-7.3-bin.zip
    
  5. Extract the downloaded ZIP file:
    sudo mkdir /opt/gradle
    sudo unzip -d /opt/gradle gradle-7.3-bin.zip
    

Step 2: Set up Environment Variables

  1. Open the .bashrc file in your home directory using a text editor such as nano or vim:
    nano ~/.bashrc
    
  2. Add the following lines at the end of the file:
    export PATH=$PATH:/opt/gradle/gradle-7.3/bin
    
  3. Save and close the file. Then, load the changes to your current session:
    source ~/.bashrc
    

Step 3: Verify Installation

To verify that Gradle has been successfully installed, run the following command:

gradle -v

If you see the version information of Gradle displayed, then the installation was successful.

Compatibility Note

If the wget command is not available on your Generic Linux distribution, you can use curl to download the Gradle distribution:

curl -LO https://services.gradle.org/distributions/gradle-7.3-bin.zip

Conclusion

In this tutorial, you have learned how to install Gradle on a Generic Linux system. Gradle is a versatile tool that can greatly enhance your Java project’s build automation process. Enjoy using Gradle for your development projects!