How to install Apache Maven on CentOS and other Linux distributions

Source: Internet
Author: User

How to install Apache Maven on CentOS and other Linux distributions

Apache Maven is an open-source automated building tool mainly used to create JAVA-based projects. Although mainly used for Java projects, Apache Maven can also be used to build and manage projects written in C #, Ruby, Scala and other languages.

To build a project, describe the software project being built, dependencies with other external modules and components, build sequence, directory, and XML files for the required plug-ins. It has predefined goals for executing some clearly defined tasks, such as compiling code and packaging.

In this tutorial, we will learn how to install Apache Maven on CentOS/RHEL. We can also install Apache Maven on Ubuntu, Debian, Fedora, and other Linux distributions using the same process mentioned below.

(Recommended: Install Jenkins on CentOS 7)

(For more information, see the complete guide to installing Apache Tomcat on Linux)

Prerequisites

We need to install JAVA 1.7 or above on the system to run Apache Maven. You can use the following command to check the installed Java version,

$ Java-version

If java is not installed on your machine, read our detailed tutorial on how to install Java on a Linux machine. Once Java is installed, we can continue to install Apache Maven.

Install

First, run the following command on the terminal to download the latest version of Apache Maven,

$ Wget http://www-us.apache.org/dist/maven/maven-3/3.5.2/binaries/apache-maven-3.5.2-bin.tar.gz

Extract the downloaded package,

$ Tar-xvzf apache-maven-3.5.2-bin.tar.gz

Move the extracted Package content to "/opt" (other folders can also be used for installation ),

$ Mv apache-maven-3.5.2/*/opt/maven

Next, we need to create a symbolic link to the maven executable file,

$ Ln-s/opt/maven/bin/mvn/usr/bin/mvn

Our Maven installation is now complete, but before we start using it, we need to set some environment variables. Run the following command to permanently set environment variables,

$ Vi/etc/profile. d/maven. sh

Add the following lines to the file,

Export M2_HOME =/usr/local/maven

Export PATH =$ {M2_HOME}/bin: $ {PATH}

Save the file and exit. Load the environment variable of the Current shell session and run the following command,

$ Source/etc/profile. d/maven. sh

In this way, Maven is installed on our system and ready to build a project.

This document describes how to install Apache Maven on a Linux machine. Please send your questions or suggestions. If you have any, please leave a message in the comment box below.

For more Maven-related tutorials, see the following:

Install Maven3.3.9 on Ubuntu 16.04

Maven official guide _ Chinese full version clear PDF

Install Maven3.3.9 on Ubuntu 16.04

Different configuration files are used in different environments when Maven is released.

Get started with Maven

Rapid deployment of Jenkins + Maven + SVN + Tomcat continuous integration environment

Build a Nexus Maven private server central repository in Ubuntu

Maven packages the Web Project and deploys it to the Tomcat server in Linux.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.