YouTube Icon

Code Playground.

How to Install Apache Maven on CentOS 8

CFG

How to Install Apache Maven on CentOS 8

Apache Maven is an open-source venture the board and understanding instrument utilized essentially for Java ventures. Expert uses a Project Object Model (POM), which is basically a XML record containing data about the venture, arrangement subtleties, the task's conditions, etc. 

In this instructional exercise, we'll disclose how to introduce Apache Maven on CentOS 8. 

The standard CentOS vaults contain Maven bundles that can be introduced with the dnf bundle director. This is the most straightforward approach to introduce Maven on CentOS. Anyway the adaptation remembered for the stores may linger behind the most recent variant of Maven. We'll additionally tell you the best way to introduce the most recent form of Maven by downloading the paired conveyance document from their official site. 

Pick the establishment technique that is generally suitable for your arrangement and climate. 

Prerequisites

The guidelines expect that you are signed in as root or client with sudo benefits . 

Introducing Apache Maven on CentOS with Dnf/Yum 

Introducing Maven on CentOS 8 utilizing dnf is a basic, clear cycle. 

Introduce Maven by entering the accompanying order in your terminal: 

sudo dnf install maven

Run the mvn - rendition order to check the establishment: 

mvn -version

The yield should look something like this: 

Apache Maven 3.5.4 (Red Hat 3.5.4-5)
Maven home: /usr/share/maven
Java version: 1.8.0_232, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.232.b09-0.el8_0.x86_64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.18.0-80.7.1.el8_0.x86_64", arch: "amd64", family: "unix"

That is it. Expert has been introduced on your CentOS framework, and you can begin utilizing it. 

Installing the Latest Release of Apache Maven

In this part, we'll give a bit by bit directions about how to introduce the most recent Apache Maven form on CentOS 8. 

1. Installing OpenJDK

Expert 3.3+ requires JDK 1.7 or above to be introduced. 

sudo dnf install java-11-openjdk-devel

sudo dnf introduce java-11-openjdk-devel 

Confirm that Java was effectively introduced by running the accompanying order: 

java -version

The yield should look something like this: 

openjdk version "11.0.5" 2019-10-15 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.5+10-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.5+10-LTS, mixed mode, sharing)

2. Download Apache Maven

At the hour of composing this article, the most recent form of Apache Maven is 3.6.3. Check the Maven download page to check whether a more up to date form is accessible. 

Start by downloading the Apache Maven file in the/tmp registry with wget order: 

wget https://www-us.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz -P /tmp

Once the download is finished, remove the file in the/select catalog: 

sudo tar xf /tmp/apache-maven-3.6.3-bin.tar.gz -C /opt

To have more authority over Maven forms and updates, we will make an emblematic connection expert that will highlight the Maven establishment catalog: 

sudo ln -s /opt/apache-maven-3.6.3 /opt/maven

To update your Maven establishment, basically unload the fresher form and change the symlink to highlight it. 

3. Setup environment variables

Next, we'll have to set up the climate factors. Open your content manager and make another document named mavenenv.sh in the/and so on/profile.d/registry. 

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

Glue the accompanying code: 

/etc/profile.d/maven.sh

export JAVA_HOME=/usr/lib/jvm/jre-openjdk
export M2_HOME=/opt/maven
export MAVEN_HOME=/opt/maven
export PATH=${M2_HOME}/bin:${PATH}

Spare and close the record. The content will be sourced at shell startup. 

Make the content executable by running the accompanying chmod order: 

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

Burden the climate factors utilizing the source order: 

source /etc/profile.d/maven.sh

4. Verify the installation

To check that Maven is introduced, utilize the mvn - form order which will print the Maven variant: 

mvn -version

 You should see something like the accompanying: 

Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /opt/maven
Java version: 11.0.5, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-11-openjdk-11.0.5.10-0.el8_0.x86_64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.18.0-80.7.1.el8_0.x86_64", arch: "amd64", family: "unix"

That is it. The most recent rendition of Maven has been introduced on your CentOS framework. 

Conclusion

We have told you the best way to introduce Apache Maven on CentOS 8. You should now visit the official Apache Maven Documentation page and figure out how to begin with Maven. 

On the off chance that you hit an issue or have input, leave a remark underneath.




CFG