In the world of Java, Apache Maven is a handy tool that helps developers manage their projects and build software more easily. It’s like a friendly assistant that guides you through the process. This guide will show you simple steps to bring Apache Maven to your Fedora system, making your Java work smoother and more organized. You don’t need to be a tech expert – just follow along, and soon you’ll have Maven at your fingertips, ready to make your project management and building tasks a breeze. Let’s dive in and make your Java development journey even more straightforward!

Advertisement

Prerequisites

  • A system running Fedora
  • Access to a terminal/command line
  • sudo or root privileges

Step 1: Update Your System

Before installing any new packages, update your system’s package repository to ensure you have access to the latest versions and patches. Open your terminal and execute the following command:

sudo dnf update

Step 2: Install Java

Maven is a Java-based tool, so you need to install the Java Development Kit (JDK) on your system. You can install OpenJDK with the following command:

sudo dnf install java-11-openjdk-devel

Verify the Java installation by running:

java -version

Step 3: Download Apache Maven

Visit the Apache Maven official website to get the link for the latest version of Maven. Use the wget command to download Maven:

wget https://dlcdn.apache.org/maven/maven-3/3.9.6/binaries/apache-maven-3.9.6-bin.tar.gz

Replace 3.9.6 with the latest version number you found on the Maven website.

Step 4: Extract and Install Maven

After downloading, extract the Maven archive to the /opt directory or another directory of your choice:

sudo tar xzf apache-maven-3.9.6-bin.tar.gz -C /opt

Step 5: Configure Environment Variables

To use Maven globally, you need to set up the M2_HOME and PATH environment variables. You can do this by creating a new file in the /etc/profile.d directory:

sudo vi /etc/profile.d/maven.sh

Add the following lines to the file:


export M2_HOME=/opt/apache-maven-3.9.6
export PATH=${M2_HOME}/bin:${PATH}

Make the script executable and load the new environment variables:

sudo chmod +x /etc/profile.d/maven.sh
source /etc/profile.d/maven.sh

Step 6: Verify Installation

To verify that Maven is installed correctly, check its version by executing:

mvn -version

This command will display the Maven version, Java version, and operating system information, confirming that Maven has been successfully installed on your Fedora system.

Conclusion

You have now successfully installed Apache Maven on your Fedora system. Maven is a powerful tool for managing Java projects, and with it, you can streamline your project builds and handle dependencies efficiently. You are now ready to create or manage Java projects using Maven on your Fedora system.

Share.

3 Comments

  1. Hi, thank you for the very descriptive and helpful tutorial. I have a couple of questions:

    Does the final step in Task 3 means that I have to run the command every time I open a new terminal?

    I wan to use maven to build a java project so do I have to run this command every time I build the project again after changes?

Leave A Reply


Exit mobile version