How to Install Apache Maven on Fedora 30/29/28

Step 1 – Prerequisites

Java development kit is the primary requirement of Apache Maven. So you need to install the Java development kit (JDK) on your system. Make sure you have installed JDK, not JRE.

java -version 

openjdk version "11.0.4" 2019-07-16
OpenJDK Runtime Environment 18.9 (build 11.0.4+11)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.4+11, mixed mode, sharing)

If you don’t have Java Development Kit installed on your system. Visit Install Java on Fedora

Step 2 – Install Apache Maven

After verifying java version on your system. Download Apache Maven from its official website or use the following command to download Apache Maven.

cd /opt
wget https://www-eu.apache.org/dist/maven/maven-3/3.6.2/binaries/apache-maven-3.6.2-bin.tar.gz

Now extract downloaded archive using following command.

sudo tar xzf apache-maven-3.6.2-bin.tar.gz
sudo ln -s apache-maven-3.6.2 maven

Step 3 – Setup Environment Variables

As you have downloaded precompiled Apache Maven files on your system. Now set the environments variables by creating new file /etc/profile.d/maven.sh.

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

and add the following content.

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

Now load the environment variables in current shell using following command.

source /etc/profile.d/maven.sh

Step 4 – Check Maven Version

Apache Maven has been successfully configured on your system. Use the following command to check the version of installed Maven on your system.

mvn -version

Apache Maven 3.6.2 (40f52333136460af0dc0d7232c0dc0bcf0d9e117; 2019-08-27T15:06:16Z)
Maven home: /opt/maven
Java version: 11.0.4, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-11-openjdk-11.0.4.11-0.fc30.x86_64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.0.16-300.fc30.x86_64", arch: "amd64", family: "unix"

Finally, remove the downloaded archive file from the system to free disk space.

rm -f apache-maven-3.6.2-bin.tar.gz
Was this answer helpful?

Related Articles

How to Enable CSF Firewall Web UI

Step 1 – Install Required Perl Modules: CSF UI required some of Perl modules to be installed...

How to Install and Configure CSF Firewall on Linux

Step 1: Download CSF Source Archive Download latest CSF archive source code from its official...

How To Install mod_cloudflare for Apache on Ubuntu

Install mod_cloudflare for Apache First of all, enable the PPA of Cloudflare module to your...

How To Install Wine 4.0 on CentOS 8 & Fedora 30/29

Step 1 – Prerequisite First of all, become root user on your CentOS 8 system. Then continue to...

How to Install Fail2Ban on CentOS 8 & Fedora 30/29

Step 1 – Install Fail2ban on CentOS 8 First of all, install epel-release package to configure...