Download the Maven, for example apache-maven-3.1.1-bin.tar.gz. Extracts it, tar -xvf apache-maven-3.1.1-bin.tar.gz Set Maven command in environment variable: Update /. Bashprofile – create this file if doesn’t exist. To download Maven, navigate to and click on the For Linux/Unix/Mac Binary tar.gz download file to install the latest version of Apache Maven.
- 1Maven Install
- 1.2Mac
Maven Install
Windows
- Download and install Maven (at least version 2.2.1) from the Apache Maven Project site.
- Add <MAVEN_HOME>bin to your “Path” System Variable. (How do I add to my Path System Variable?)
Mac
The following is from http://maven.apache.org/download.html for installing maven
- In a command terminal, add the M2_HOME environment variable, e.g. export M2_HOME=/usr/local/apache-maven/apache-maven-2.2.1.
- Add the M2 environment variable, e.g. export M2=$M2_HOME/bin.
- Optional: Add the MAVEN_OPTS environment variable to specify JVM properties, e.g. export MAVEN_OPTS=-Xms256m -Xmx512m. This environment variable can be used to supply extra options to Maven.
- Add M2 environment variable to your path, e.g. export PATH=$M2:$PATH.
- Make sure that JAVA_HOME is set to the location of your JDK, e.g. export JAVA_HOME=/usr/java/jdk1.6.0_16 and that $JAVA_HOME/bin is in your PATH environment variable.
- Run mvn --version to verify that it is correctly installed.
Using Macports
Using Macports you can greatly increase the simplicity of installing Maven2.
- Install Macports if it is not already. [1]
- In a command terminal type 'ports install maven2'
Linux
See Mac Maven Install above.
Configure Maven (Deprecated)
(The following steps are no longer be necessary for calendar or directory to run. They will eventually be removed from this page.)
If you cannot access the maven repository configured for your project, you like
- Add the following to your <MAVEN_HOME>confsettings.xml inside of the servers tag: (change the username and password)
- You can also add the same code to your <HOME>.m2settings.xml:
In this tutorial, we will be going through the installation process of Maven.
If you are a WINDOWS user (if you are not, scroll down to view how to install Maven if you are a Linux or Mac user):
Before proceeding with the next steps, make sure you have JDK installed on your system. If you don’t, you can view this article for a quick step-by-step guide. To view all the necessary minimum requirements for Maven, either click here or view the image below
Download And Install Maven On Mac Download
Click here and download the latest version. You can either select the Binary version or the full version (a.k.a. with source and docs). I recommend downloading the Binary one as you can find all the source and docs online anyway.
Select the Binary edition if you don’t want the source and docs included in it. When you click on the link, it should automatically start downloading the zip file. If it doesn’t refresh the page and try again.
After your download is complete, extract the archive to C and preferably, create a folder in C named Maven and extract the files into there.
After you have created the Maven folder, extract the files from the downloaded zip file into that folder.
Now we have to set up M2_HOME. Before being able to run Maven, we need to set it in the environment variables and add the “bin” to PATH.
Adding M2_HOME
- Right-click somewhere on This PC
- Select Properties
- On the right, select Advanced System Settings
- After that, click on “Environmental Variables…”
- Under “System variables” select New…
- When the input box opens, type M2_HOME as a variable name and the path to the maven
- Under System variables, select “Path” and click on Edit…
- Add the path “C:Mavenapache-maven-3.6.1bin”
Verifying if the installation has been successful
To know if the installation has been successful for you, type this in the CMD:
If you get something like:
then you are good to go.
Linux
Requirements:
- Download apache-maven-3.6.1-bin.tar.gz binary (if you do not want the source and docs included).
- type
cd /opt
in the terminal - extract the apache-maven archive into the opt directory:
sudo tar -xvzf ~/Downloads/apache-maven-3.6.0-bin.tar.gz
- Add as environment variable:
M2_HOME='/opt/apache-maven-3.6.0
and append the bin directory to the Path variable:'
/opt/apache-maven-3.6.0/bin
- Update the mvn command:
sudo update-alternatives --install '/usr/bin/mvn' 'mvn' '/opt/apache-maven-3.6.0/bin/mvn' 0
sudo update-alternatives --set mvn /opt/apache-maven-3.6.0/bin/mvn
- Add bash completion to mvn:
sudo wget https://raw.github.com/dimaj/maven-bash-completion/master/bash_completion.bash --output-document /etc/bash_completion.d/mvn
. This will allow you to complete Maven commands by hitting Tab a couple of times. - Type mvn –version to verify if it works
MAC
- Open the terminal and go to the directory in which the files were extracted and login as Super User
- Remove the tar.gz archive by typing rm Downloads/apache-maven*bin.tar.gz
- Fix the permissions: chown -R root:wheel Downloads/apache-maven*
- Switch the maven contents: mv Downloads/apache-maven* /opt/apache-maven
- Archive the Admin session: exit
- Add Maven binaries to the path and then append:
- nano $HOME/.profile
- export PATH=$PATH:/opt/apache-maven/bin
- Ctrl + x to Save and Exit from nano
- To load the new set up execute bash
- To test if the installation has been successful, type mvn -version
Related Tutorials
Maven Download For Mac
- How to create Java JAR file with Maven
This tutorial will explain how to create Java JAR file with Maven with step by step guidelines and screen shots. Why Need a Java JAR…
- How to Install and Configure Tomcat 8
Apache Tomcat is the most common and popular java-based web container available today. In this tutorial I will show you how to install Tomcat 8…
- Install Java 8 JDK on Ubuntu
In this tutorial you will learn how to install latest Java 8 on Ubuntu or LinuxMint via PPA. If you are using Windows please check…