Maven – Setup Guide
Installation
Maven is a Java tool, so you must have Java installed in order to proceed.
System Requirements
Java Development Kit (JDK) | Maven 3.3+ require JDK 1.7 or above to execute – they still allow you to build against 1.3 and other JDK versions by Using Toolchains |
Memory | No minimum requirement |
Disk | Approximately 10MB is required for the Maven installation itself. In addition to that, additional disk space will be used for your local Maven repository. The size of your local repository will vary depending on usage but expect at least 500MB. |
Operating System | No minimum requirement. Start up scripts are included as shell scripts and Windows batch files. |
Steps to Setup Maven
- Download Apache Maven
- Extract Apache Maven
- Ensure JAVA_HOME in Environment Variable
- Add MAVEN to Environmental Variable
- Ensure Maven Installation
Download Apache Maven
When I was writing this article, Apache Maven 3.6.0 is the latest release and recommended version for all users. While you read this article, Maven might have released some other version and you can continue to setup the latest version. Apache Maven can be downloaded from below link,
https://maven.apache.org/download.cgi
Maven is distributed in several formats for your convenience. Simply pick a ready-made binary distribution archive and follow the installation instructions. Use a source archive if you intend to build Maven yourself.
Extract Apache Maven
Once downloaded, Extract distribution archive in any directory.
unzip apache-maven-3.6.0-bin.zip
or
tar xzvf apache-maven-3.6.0-bin.tar.gz
Alternatively use your preferred archive extraction tool.
Ensure JAVA_HOME in Environment Variable
Ensure JAVA_HOME environment variable is set and points to your JDK installation.
Add MAVEN to Environmental Variable
Navigate to Environment variable and add bin directory of MAVEN installation directory.
Ensure Maven Installation
Open a new command prompt (Winkey + R then type cmd) and run mvn -v to verify the installation. The result should look similar to,
Apache Maven 3.5.3 (3383c37e1f9e9b3bc3df5050c29c8aff9f295297; 2018-02-25T01:19:05+05:30) Maven home: C:\apache-maven-3.5.3\bin\.. Java version: 1.8.0_171, vendor: Oracle Corporation Java home: C:\Program Files\Java\jre1.8.0_171 Default locale: en_IN, platform encoding: Cp1252 OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
In my case, my machine was already installed with Apache Maven 3.5.3. So don’t get confused with version.
Unix-based Operating System (Linux, Solaris and Mac OS X) Tips
- Check environment variable value
echo $JAVA_HOME /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home
- Adding to PATH
export PATH=/opt/apache-maven-3.6.0/bin:$PATH
Conclusion
Hence the Maven setup is so easy to complete with few steps and verification.