How To Install Gradle on AlmaLinux 10

Gradle has become the go-to build automation tool for modern software development, powering millions of projects worldwide from Android applications to enterprise Java systems. This powerful, flexible build system combines the best features of Apache Maven and Ant while introducing its own declarative build language based on Groovy and Kotlin. If you’re running AlmaLinux 10 and need to set up Gradle for your development environment, this comprehensive guide walks you through every step of the installation process.
The latest Gradle version brings significant performance improvements, enhanced dependency management, and better support for multi-project builds. Whether you’re an experienced developer or just getting started with Java-based projects, installing Gradle correctly ensures smooth project compilation, testing, and deployment. This tutorial provides detailed instructions tested on AlmaLinux 10, complete with troubleshooting tips and best practices to help you avoid common pitfalls.
What is Gradle?
Gradle represents a modern approach to build automation that addresses the limitations of earlier tools. As an open-source build automation system, it excels at managing complex project dependencies, executing tests, and packaging applications for deployment. Originally designed for Java projects, Gradle now supports multiple programming languages including Kotlin, Groovy, Scala, and C++.
What sets Gradle apart is its flexibility and performance. Unlike Maven’s rigid XML-based configuration, Gradle uses a domain-specific language that allows developers to write build logic using actual code. This approach enables conditional logic, loops, and custom tasks that would be cumbersome or impossible in traditional build tools. The incremental build feature ensures that only modified components get recompiled, dramatically reducing build times for large projects.
Android developers will recognize Gradle as the official build tool for Android Studio. Its robust plugin ecosystem, parallel execution capabilities, and intelligent caching make it ideal for projects of any size. The build cache can be shared across teams, ensuring consistent builds and faster compilation times across development, testing, and production environments.
Prerequisites
Before installing Gradle on your AlmaLinux 10 system, ensure you meet these requirements to avoid installation issues.
System Requirements
Your AlmaLinux 10 installation should have at least 2 GB of RAM, though 4 GB is recommended for optimal performance when working with larger projects. Allocate at least 20 GB of available disk space to accommodate Gradle, its dependencies, build caches, and your development projects. A stable internet connection is essential for downloading Gradle binaries and resolving project dependencies from remote repositories.
Required Software
You’ll need root or sudo privileges to install system packages and configure environment variables. The Java Development Kit (JDK) version 8 or higher is mandatory, though JDK 11 or 17 is recommended for compatibility with Gradle 9.x and newer versions. Additionally, ensure your system has wget or curl for downloading files, the unzip utility for extracting archives, and a text editor like nano or vi for configuration file editing.
Knowledge Prerequisites
Basic familiarity with Linux command-line operations will make this installation process smoother. Understanding how environment variables work and basic system administration concepts helps you troubleshoot potential issues. Check your AlmaLinux version by running cat /etc/almalinux-release to confirm you’re on version 10.
Step 1: Update AlmaLinux System
Keeping your system updated is crucial for security and compatibility. Before installing new software, update your AlmaLinux 10 package repository and existing packages to their latest versions.
Open your terminal and execute the following command with sudo privileges:
sudo dnf update -y
This command refreshes the package repository metadata and upgrades all installed packages. The -y flag automatically confirms the update without prompting for user input. Depending on how recently you’ve updated your system, this process might take a few minutes.
If you haven’t already enabled the EPEL (Extra Packages for Enterprise Linux) repository, install it now:
sudo dnf install epel-release -y
EPEL provides additional packages that aren’t included in the standard AlmaLinux repositories. After the update completes, you’ll see a “Complete!” message indicating that your system is ready for the next steps.
Step 2: Install Java Development Kit (JDK)
Gradle requires a Java runtime environment to function. The JDK provides not only the Java runtime but also development tools necessary for building and compiling projects.
Why JDK is Required
Gradle itself is written in Java and runs on the Java Virtual Machine (JVM). While you could technically use just the Java Runtime Environment (JRE), the JDK is essential for compiling Java source code in your projects. Gradle 9.x requires JDK 8 as a minimum, but OpenJDK 11 or 17 provides better performance and long-term support.
Installation Commands
First, check which JDK versions are available in your AlmaLinux repositories:
sudo dnf search openjdk
Install OpenJDK 17, the latest Long-Term Support (LTS) version:
sudo dnf install java-17-openjdk java-17-openjdk-devel wget unzip -y
This single command installs the JDK, development tools, wget, and unzip utilities. The installation process downloads approximately 200-300 MB of packages and completes within a few minutes.
Verification Steps
Confirm that Java installed correctly by checking the version:
java -version
You should see output displaying OpenJDK version 17 along with build information. Next, verify the Java compiler:
javac -version
This command confirms that the development tools are properly installed. If you receive a “command not found” error, the JDK installation may have failed or the PATH variable needs updating.
Setting JAVA_HOME
While not always mandatory, many Java applications expect the JAVA_HOME environment variable to point to your JDK installation. Locate your Java installation directory:
readlink -f $(which java)
This command reveals the full path to your Java installation, typically /usr/lib/jvm/java-17-openjdk-17.x.x.x. You can set JAVA_HOME temporarily in your current session or configure it permanently in the next steps alongside Gradle environment variables.
Step 3: Download Gradle
With Java installed, you’re ready to download the Gradle distribution from the official source.
Choosing the Right Version
Gradle releases come in two distribution types: binary-only and complete. The binary-only distribution contains everything needed to run Gradle, while the complete distribution includes source code and documentation. For most users, the binary-only distribution is sufficient and smaller in size. As of December 2025, Gradle 9.1.0 represents the latest stable release with performance improvements and new features.
Download Methods
Navigate to a temporary directory and download Gradle using wget:
cd /tmp
wget https://services.gradle.org/distributions/gradle-9.1.0-bin.zip
The download is approximately 100-120 MB and should complete within minutes depending on your connection speed. Alternatively, use curl if you prefer:
curl -L https://services.gradle.org/distributions/gradle-9.1.0-bin.zip -o gradle-9.1.0-bin.zip
The -L flag tells curl to follow redirects, ensuring you download from the correct distribution server.
Verification
For enhanced security, verify the downloaded file’s integrity by checking its SHA-256 checksum. Download the checksum file from the Gradle website and compare it with your download:
sha256sum gradle-9.1.0-bin.zip
Compare the output with the official checksum published on the Gradle releases page. This step, while optional, ensures your download hasn’t been corrupted or tampered with.
Step 4: Extract and Install Gradle
Now that you’ve downloaded Gradle, extract it to a permanent location on your system.
Create Installation Directory
The /opt directory is the standard location for optional software packages on Linux systems. Create a dedicated Gradle directory:
sudo mkdir -p /opt/gradle
The -p flag ensures the command succeeds even if the directory already exists, preventing errors during repeated installations.
Extract Archive
Extract the downloaded Gradle archive directly to your installation directory:
sudo unzip -d /opt/gradle /tmp/gradle-9.1.0-bin.zip
This command extracts the contents to /opt/gradle, creating a subdirectory named gradle-9.1.0 containing all necessary files. The extraction process completes in seconds.
Verify the installation by listing the extracted contents:
ls /opt/gradle/gradle-9.1.0
You should see directories including bin (containing executables), lib (containing libraries), init.d (for initialization scripts), and several license and readme files.
Directory Structure
Understanding Gradle’s directory layout helps with troubleshooting. The bin directory contains the gradle executable script that you’ll run to execute builds. The lib directory houses all Java archives (JAR files) that Gradle needs to function. Keep this structure intact to ensure proper operation.
Cleanup
Remove the downloaded zip file to free up disk space:
rm /tmp/gradle-9.1.0-bin.zip
Your Gradle installation now occupies approximately 150-200 MB in the /opt/gradle directory.
Step 5: Configure Environment Variables
To run Gradle commands from any directory, configure system-wide environment variables that point to your installation.
Why Environment Variables Matter
The PATH variable tells your shell where to find executable programs. Adding Gradle’s bin directory to PATH allows you to type gradle instead of the full path /opt/gradle/gradle-9.1.0/bin/gradle. The GRADLE_HOME variable helps other tools and scripts locate your Gradle installation.
Create Gradle Profile Script
Create a new script in the /etc/profile.d/ directory, which automatically loads for all users at login:
sudo nano /etc/profile.d/gradle.sh
Add the following content to the file:
export GRADLE_HOME=/opt/gradle/gradle-9.1.0
export PATH=${GRADLE_HOME}/bin:${PATH}
Save and exit the editor (in nano, press Ctrl+X, then Y, then Enter). These export statements define GRADLE_HOME and prepend Gradle’s bin directory to your existing PATH.
Set Permissions
Make the script executable so the system processes it during login:
sudo chmod +x /etc/profile.d/gradle.sh
The execute permission ensures the script runs automatically for all users when they start a new shell session.
Apply Changes
Load the environment variables into your current session without logging out:
source /etc/profile.d/gradle.sh
This command immediately applies the changes. Alternatively, you can log out and log back in for the variables to take effect automatically.
Verification
Confirm that the environment variables are set correctly:
echo $GRADLE_HOME
This should output /opt/gradle/gradle-9.1.0. Check that Gradle appears in your PATH:
echo $PATH | grep gradle
You should see the Gradle bin directory included in the output.
Persistent Configuration
The changes you’ve made persist across reboots because scripts in /etc/profile.d/ execute automatically during login. If you prefer user-specific configuration instead of system-wide, add the export statements to your ~/.bashrc or ~/.bash_profile file instead.
Step 6: Verify Gradle Installation
With everything configured, verify that Gradle works correctly on your system.
Basic Verification
Check the installed Gradle version:
gradle -v
Or use the long form:
gradle --version
You’ll see comprehensive output including the Gradle version (9.1.0), build time, revision hash, Groovy version, Kotlin version, JVM version and vendor, and operating system information. This confirms that Gradle can locate Java, load its libraries, and execute successfully.
Test Gradle Functionality
Create a test directory and initialize a new Gradle project:
mkdir ~/gradle-test
cd ~/gradle-test
gradle init
Gradle launches an interactive setup wizard. Select “application” as the project type, “Java” as the language, and “Groovy” or “Kotlin” as your build script DSL. The initialization process creates a complete project structure with sample source files, build scripts, and the Gradle Wrapper.
Common Verification Issues
If you encounter “gradle: command not found,” your PATH variable isn’t configured correctly. Re-check the environment variable setup and ensure you’ve sourced the profile script or started a new terminal session.
Permission denied errors typically indicate incorrect file permissions on the Gradle installation directory or executable. Verify ownership and permissions:
ls -la /opt/gradle/gradle-9.1.0/bin/gradle
The file should be readable and executable by all users.
Creating Your First Gradle Project
Understanding how to create and structure Gradle projects helps you start development quickly.
Initialize New Project
Navigate to your desired project location and run:
gradle init
The interactive wizard prompts you for several choices:
- Project type: application (runnable), library (reusable component), or basic (minimal structure)
- Language: Java, Kotlin, Groovy, Scala, C++, or Swift
- Build script DSL: Kotlin or Groovy syntax
- Test framework: JUnit, TestNG, or Spock
- Project name and source package
Answer each prompt based on your project requirements. Gradle generates appropriate files and directories automatically.
Understanding Project Structure
Examine the generated structure:
tree .
You’ll find build.gradle or build.gradle.kts (the build configuration), settings.gradle (project settings), src/main/java (source code), src/test/java (test code), and gradlew plus gradlew.bat (Gradle Wrapper scripts).
The build file defines dependencies, plugins, and tasks. The settings file configures multi-project builds. The src directory follows Maven’s standard directory layout for compatibility.
Build and Run
Compile and build your project:
gradle build
Gradle downloads dependencies, compiles source code, runs tests, and packages your application. The first build takes longer as Gradle populates its dependency cache. Subsequent builds leverage caching for speed.
Run your application:
gradle run
For applications, this task compiles and executes your main class, displaying output in the terminal.
Gradle Wrapper Benefits
The Gradle Wrapper (gradlew) is a script that downloads and runs a specific Gradle version automatically. This ensures everyone on your team uses the same Gradle version regardless of what’s installed on their system. Commit the wrapper files to version control for consistency across development environments.
Gradle Configuration Best Practices
Optimize your Gradle setup for better performance and maintainability.
Performance Optimization
Enable the Gradle daemon to keep a background process running between builds, reducing startup time:
Create or edit ~/.gradle/gradle.properties:
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.caching=true
org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m
The daemon setting keeps Gradle loaded in memory. Parallel execution runs independent modules simultaneously. Build caching reuses outputs from previous builds. The JVM arguments allocate 2 GB heap memory and 512 MB for metadata.
Build Script Organization
Keep build scripts clean and maintainable. Extract common configuration into separate files. Use version catalogs (a Gradle 9.x feature) to manage dependency versions centrally:
// settings.gradle.kts
dependencyResolutionManagement {
versionCatalogs {
create("libs") {
library("junit", "junit:junit:4.13.2")
}
}
}
Security Considerations
Always use HTTPS URLs for repositories to prevent man-in-the-middle attacks. Enable dependency verification to detect compromised artifacts. Avoid hardcoding credentials in build scripts; use environment variables or Gradle properties files instead.
Updating Gradle
Keep Gradle updated to benefit from bug fixes, security patches, and new features.
When to Update
Monitor major version releases for significant new features. Minor versions bring incremental improvements and bug fixes. Security patches require immediate attention. Review release notes before upgrading to understand breaking changes.
Update Process
Download the new version following the same process used for installation. Extract it to a new directory like /opt/gradle/gradle-9.2.0. Update the environment variables in /etc/profile.d/gradle.sh to point to the new version. Source the script to apply changes immediately.
Using Gradle Wrapper for Updates
For project-specific updates, use the wrapper:
./gradlew wrapper --gradle-version=9.1.0
This updates the wrapper configuration without changing your system installation. Each project can use different Gradle versions as needed.
Rollback Strategy
Keep previous Gradle versions installed by not deleting old directories. If an update causes issues, simply revert the environment variables to point back to the working version. This provides a quick recovery path while you troubleshoot compatibility problems.
Troubleshooting Common Issues
Address frequent problems that may arise during installation and usage.
Issue 1: Java Version Incompatibility
Symptoms: Error messages stating “Unsupported class file major version” or “Gradle requires Java 8 or higher.”
Solution: Verify Java version compatibility. Gradle 9.x requires JDK 8 minimum but works best with JDK 11 or 17. Check your Java version with java -version. If multiple Java versions are installed, configure JAVA_HOME to point to the correct version or use alternatives to switch the default Java:
sudo alternatives --config java
Issue 2: Permission Denied Errors
Symptoms: Cannot execute gradle commands; “Permission denied” when running gradle.
Solution: Check file permissions on the Gradle binary:
ls -l /opt/gradle/gradle-9.1.0/bin/gradle
The file needs execute permissions. Fix with:
sudo chmod +x /opt/gradle/gradle-9.1.0/bin/gradle
On AlmaLinux, SELinux might block execution. Check SELinux context and temporarily set to permissive mode if needed for testing:
sudo setenforce 0
Issue 3: Environment Variables Not Persisting
Symptoms: Gradle commands work in one terminal session but fail after rebooting or opening new terminals.
Solution: Verify /etc/profile.d/gradle.sh exists and has execute permissions. Check for syntax errors in the file. Ensure the file doesn’t contain Windows line endings if you edited it on a Windows system. Convert line endings with:
dos2unix /etc/profile.d/gradle.sh
Issue 4: Slow Build Performance
Symptoms: Builds take excessively long, even for small changes.
Solution: Enable the Gradle daemon if not already active. Configure build caching in gradle.properties. Increase heap memory allocation for large projects. Check network connectivity, as slow dependency downloads significantly impact build time. Consider using a local repository mirror for frequently used dependencies.
Issue 5: Dependency Download Failures
Symptoms: “Could not resolve dependency” or timeout errors when downloading libraries.
Solution: Verify internet connectivity and DNS resolution. Check firewall rules that might block Gradle’s dependency downloads. If behind a corporate proxy, configure proxy settings in ~/.gradle/gradle.properties:
systemProp.http.proxyHost=proxy.example.com
systemProp.http.proxyPort=8080
systemProp.https.proxyHost=proxy.example.com
systemProp.https.proxyPort=8080
Getting Help
Consult the official Gradle documentation for detailed reference materials. The Gradle community forums provide peer support for common issues. Stack Overflow hosts thousands of answered Gradle questions. Generate build scans with gradle build --scan to share detailed diagnostic information when seeking help. The AlmaLinux community forums can assist with OS-specific concerns.
Uninstalling Gradle
Remove Gradle completely if you need to start fresh or no longer require it.
When to Uninstall
Uninstall when migrating to a different build system, cleaning up unused software, or preparing for a fresh installation to resolve persistent issues.
Uninstallation Steps
Remove the Gradle installation directory:
sudo rm -rf /opt/gradle/gradle-9.1.0
Delete the environment variable script:
sudo rm /etc/profile.d/gradle.sh
Clear the environment variables in your current session:
unset GRADLE_HOME
export PATH=$(echo $PATH | sed -e 's|:/opt/gradle/gradle-9.1.0/bin||')
Verification
Confirm Gradle is no longer accessible:
gradle -v
This should return “command not found.” Check that environment variables are removed with echo $GRADLE_HOME (should be empty).
Cleanup User Data
Optionally remove cached files and downloaded dependencies:
rm -rf ~/.gradle
This directory contains build caches, wrapper distributions, and dependency caches. Removing it frees disk space but means future Gradle projects must re-download dependencies. Keep this directory if you plan to reinstall Gradle soon.
Congratulations! You have successfully installed Gradle. Thanks for using this tutorial for installing Gradle on your AlmaLinux OS 10 system. For additional help or useful information, we recommend you check the official Gradle website.