Install and configure Apache Maven in Ubuntu Linux

Source: Internet
Author: User

Install and configure Apache Maven in Ubuntu Linux

Operating System: Linux x64/Ubuntu 14.04

Apache Maven version: 3.3.9

We recommend that you set up a Java Development Environment in advance. For details, see the previous article "setting up a Java Development Environment in Ubuntu Linux".

1. Go to the Apache Maven official website to download the latest version: Latest.

2. Create a folder in the appropriate path to store Maven. In this example, create an MVN sub-folder under the/opt directory. The operations are as follows:

Open Terminal (the last is T1) and enter:

Cd/opt # Go to the opt directory
Sudo mkdir mvn # create an mvn folder
Ls # the newly created mvn folder is displayed.
Cd mvn # enter the mvn folder

3. Copy the downloaded MVN package to the mvn directory. The operations are as follows:

Create another Terminal window (T2) and enter:

Cd Downloads # enter the Downloads folder
Ls # display the MVN file just downloaded,
Sudo cp apache-maven-3.3.9-bin.tar.gz/opt/mvn # copy the file to the newly created mvn folder (here Replace the "<>" section with your own MVN file name, which is later the same)
Sudo rm apache-maven-3.3.9-bin.tar.gz # Delete the installation package in the local directory (optional)

4. decompress and install MVN to configure environment variables. The operations are as follows:

Return to the first Terminal (T1) and enter:

Ls # display the copied MVN installation package
Sudo tar-zxvf apache-maven-3.3.9-bin.tar.gz # unzip the installation package
Ls # display the decompressed MVN folder and the original installation package
Sudo rm apache-maven-3.3.9-bin.tar.gz # delete original installation package
Sudo gedit/etc/profile # Open the profile file under the etc directory

5. configure global environment variables. The operations are as follows:

Add the MVN installation path at the end of the open profile document (confirm carefully ):

# Set maven environment
Export M2_HOME =/opt/mvn/apache-maven-3.3.9
Export MAVEN_OPTS = "-Xmx1024m" # Avoid memory overflow errors (optional)
Export PATH =$ {M2_HOME}/bin: $ {PATH}

6. Save and close the document. (Note: You can also run the vim command to edit etc/profile, open the command: sudo vim/etc/profile, press <Insert> to enter the edit mode, and <Esc> to exit the edit mode, press ":" and then enter "wq! "Save and exit; enter" q! "Do not save and Exit)

7. Enable configuration and verify. In Terminal, enter:

Mvn-v

8. The display effect is similar to the following:

Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09425c07478323dc5; 2015-11-10T08: 41: 47-08:00)
Maven home:/opt/developTools/jjvm/apache-maven-3.3.9
Java version: 1.8.0 _ 65, vendor: Oracle Corporation
Java home:/opt/developTools/jvm/jdk1.8.0 _ 65/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.19.0-25-generic", arch: "amd64", family: "unix"

Maven official guide _ Chinese full version clear PDF

Maven 3.1.0 release, Project Build Tool

Install Maven in Linux

Maven3.0 configuration and simple use

Set up sun-jdk and Maven2 in Ubuntu

Get started with Maven

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.