Gradle is a free and open-source build automation tool used for developing different applications. It uses Groovy to define project configurations. Gradle is compatible with Java, Javascript, and C/C++. It helps you to manage required libraries, deployment, testing, and notifications of the application in different platforms. Gradle is very popular due to its simplicity, ease of use, and prebuilt functionality.
In this post, we will show you how to install Gradle on Debian 12.
Step 1 – Install Java JDK
Gradle is a Java-based application, so Java JDK must be installed on your server. If not installed you can install it by running the following command:
apt-get update -y apt-get install default-jdk -y
Once Java JDK is installed, verify the Java installation using the command given below:
java --version
You will get the following output:
openjdk 17.0.16 2025-07-15 OpenJDK Runtime Environment (build 17.0.16+8-Debian-1deb12u1) OpenJDK 64-Bit Server VM (build 17.0.16+8-Debian-1deb12u1, mixed mode, sharing)
Step 2 – Install Gradle on Debian 12
First, install the required dependencies using the following command:
apt-get install curl unzip -y
Next, download the latest version of Gradle using the following command:
wget https://services.gradle.org/distributions/gradle-9.0.0-all.zip
Once the download is completed, unzip the downloaded file with the following command:
unzip gradle-9.0.0-all.zip
Next, move the extracted directory to /opt with the following command:
mv gradle-9.0.0 /opt/gradle
Now, run the following command to list all files and directories inside /opt/gradle directory:
ls /opt/gradle/
You should see the following output:
bin init.d lib LICENSE NOTICE README
Step 3 – Set up Environment Variable
Next, you will need to create an environment variable for Gradle. You can create it by running the following command:
echo "export PATH=/opt/gradle/bin:${PATH}" | tee /etc/profile.d/gradle.sh
Next, set executable permissions to the gradle.sh file:
chmod +x /etc/profile.d/gradle.sh
Next, activate the environment variable using the following command:
source /etc/profile.d/gradle.sh
Step 4 – Verify the Gradle Installation
At this point, Gradle is installed in your system. You can now verify the Gradle installation using the following command:
gradle -v
You should see the following output:
Welcome to Gradle 9.0.0! Here are the highlights of this release: - Configuration Cache is the recommended execution mode - Gradle requires JVM 17 or higher to run - Build scripts use Kotlin 2.2 and Groovy 4.0 - Improved Kotlin DSL script compilation avoidance For more details see https://docs.gradle.org/9.0.0/release-notes.html ------------------------------------------------------------ Gradle 9.0.0 ------------------------------------------------------------ Build time: 2025-07-31 16:35:12 UTC Revision: 328772c6bae126949610a8beb59cb227ee580241 Kotlin: 2.2.0 Groovy: 4.0.27 Ant: Apache Ant(TM) version 1.10.15 compiled on August 25 2024 Launcher JVM: 17.0.16 (Debian 17.0.16+8-Debian-1deb12u1) Daemon JVM: /usr/lib/jvm/java-17-openjdk-amd64 (no JDK specified, using current Java home) OS: Linux 6.1.0-32-amd64 amd64
Step 5 – Create a Project with Gradle
In this section, we will show you how to create a sample project with Gradle.
First, create a directory for your project:
mkdir project
Next, navigate to the project directory and initialize the project with the following command:
cd project gradle init
You will be asked to select the type of project to generate:
Starting a Gradle Daemon (subsequent builds will be faster) Select type of build to generate: 1: Application 2: Library 3: Gradle plugin 4: Basic (build structure only) Enter selection (default: Application) [1..4] 4
Type 4 and press the Enter key. You will be asked to select the build script:
Select build script DSL: 1: Groovy 2: Kotlin Enter selection (default: Groovy) [1..2] 1
Type 1 and press Enter key. Once the project has been built successfully, you will get the following output:
Generate build using new APIs and behavior (some features may change in the next minor release)? (default: no) [yes, no] Project name (default: project): > Task :init Learn more about Gradle by exploring our Samples at https://docs.gradle.org/9.0.0/samples BUILD SUCCESSFUL in 1m 7s 1 actionable task: 1 executed Consider enabling configuration cache to speed up this build: https://docs.gradle.org/9.0.0/userguide/configuration_cache_enabling.html
You can list your project files using the following command:
ls
You should see the following output:
build.gradle.kts gradle gradle.properties gradlew gradlew.bat settings.gradle.kts
Conclusion
Congratulations! You have successfully installed Gradle on Debian 12. You can now start deploying your application using Gradle. Try it on dedicated hosting from Atlantic.Net!