FedoraRHEL Based

How To Install Gradle on Fedora 39

Install Gradle on Fedora 39

In this tutorial, we will show you how to install Gradle on Fedora 39. Gradle is a powerful and flexible build automation tool that has become the go-to choice for many Java developers. It simplifies the process of managing dependencies, configuring build settings, and automating tasks, making it an essential tool for efficient Java development. Gradle is also the official build tool for Android development, making it a must-have for anyone working on Android projects. The good news is that Gradle runs seamlessly on all major operating systems, including Fedora Linux.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Gradle on a Fedora 39.

Prerequisites

Before diving into the installation process, let’s ensure that you have everything you need:

    • A server running one of the following operating systems: Fedora 39.
    • It’s recommended that you use a fresh OS install to prevent any potential issues.
    • You will need access to the terminal to execute commands. Fedora 39 provides the Terminal application for this purpose. It can be found in your Applications menu.
    • A network connection or internet access to download the Gradle package.
    • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Gradle on Fedora 39

Step 1. Keeping your system up-to-date is crucial for security and stability. Start by running the following command to update your Fedora 39 installation:

sudo dnf clean all
sudo dnf update

Step 2. Installing Java.

The first step is to check if a compatible version of Java is already installed on your Fedora system. Open a terminal and run the following command:

java -version

If Java is installed, you’ll see output indicating the Java version. If the version is 1.8 (Java 8) or higher, you’re good to go. However, if Java is not installed or the version is older than Java 8, you’ll need to install a compatible version.

To install Java on Fedora 39, you can use the DNF package manager. Run the following command in the terminal:

sudo dnf install java-11-openjdk

Step 3. Installing Gradle on Fedora 39.

With Java installed, we can now proceed to download Gradle. Visit the official Gradle releases page at https://gradle.org/releases/ in your web browser. On this page, you’ll find a list of available Gradle versions.

Open a terminal and navigate to the directory where you want to download Gradle. Then, use the wget command to download the .zip file. For example:

wget https://downloads.gradle-dn.com/distributions/gradle-8.6-bin.zip

Once the Gradle .zip file is downloaded, we need to extract its contents. It’s a good practice to install Gradle in a dedicated directory to keep your system organized. We’ll use the /opt/gradle directory for this purpose.

Create the /opt/gradle directory by running the following command:

sudo mkdir /opt/gradle

Now, extract the downloaded .zip file to the /opt/gradle directory using the unzip command:

sudo unzip -d /opt/gradle gradle-8.6-bin.zip

Step 4. Configuring Environment Variables

To run Gradle from anywhere in the terminal, we need to add its bin directory to the PATH environment variable. This allows you to execute the gradle command without specifying the full path to the Gradle installation.

To make the configuration persistent across system restarts, we’ll create a gradle.sh file in the /etc/profile.d/ directory. This directory contains scripts that are executed when a user logs in or opens a new terminal session.

Open a new file named gradle.sh in the /etc/profile.d/ directory using a text editor with sudo privileges:

sudo nano /etc/profile.d/gradle.sh

Inside the file, add the following line:

export PATH=$PATH:/opt/gradle/gradle/bin

Save the file and exit the text editor. To make the script executable, run the following command:

sudo chmod +x /etc/profile.d/gradle.sh

Finally, load the environment variables by executing the script:

source /etc/profile.d/gradle.sh

With Gradle installed and the environment variables configured, it’s time to verify that everything is working correctly. Open a new terminal or reload the current session to ensure the environment variables are loaded.

Run the following command to check the installed Gradle version:

gradle -v

If the installation was successful, you should see output similar to the following:

Gradle 8.6
Build time: 2024-02-14 16:41:37 UTC
Revision: 7d6581558e226a580d91d399f7dfb9e3095c2b1d
...

Step 5. Troubleshooting Tips

If you encounter any issues during the Gradle installation or while working with Gradle projects, here are a few troubleshooting tips:

  • Ensure that you have a compatible Java version installed (JDK 8 or higher). Double-check the Java installation and verify that the java command is available in the terminal.
  • If you encounter permission-related issues, make sure you have the necessary permissions to access and modify the directories used for Gradle installation and project creation.
  • If Gradle commands are not recognized, verify that the Gradle bin directory is correctly added to the PATH environment variable. Recheck the /etc/profile.d/gradle.sh file and ensure it contains the correct path.
  • If you face issues with Gradle builds or dependencies, review the build.gradle file for any misconfigurations or missing dependencies. Consult the Gradle documentation or seek assistance from the Gradle community forums.

Congratulations! You have successfully installed Gradle. Thanks for using this tutorial for installing the Gradle on your Fedora 39 system. For additional or useful information, we recommend you check the official Gradle website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button