How to install maven on Windows and Linux/Unix

Maven is a java-based project build tool that automates the build process. To installs Maven on any platform, you’ll need a Java development environment. Before installing maven, make sure you have the most recent JDK version installed.

You can check my other posts on maven commands

maven build debug

Install and setup maven on local windows

Download maven software from apache site and extract the files, copy it local drive example D:\java\apache-maven-3.0.3.

Before that, you need to set below environment variables on your local box
set M3_HOME variable to maven home folder(for example D:\java\apache-maven-3.0.3)

add M3_HOME variable to environment variable PATH (ex:- %PATH%\%M2_HOME%\bin)

To know mvn installed correctly, open command window and execute the following command,

mvn --version  

It shows both the maven and the java versions. The screenshot for this command can be found below.

Install, configure Maven in windows

Install and setup Maven on Linux

Please download the most recent version of Maven from the Maven website. It was downloaded to your local folder as apache-maven-3.5.0-bin.tar.gz. Extract and save to usr/local/apache-maven-3.5.0, then set up maven environment variables.

export M3_HOME=/usr/local/apache-maven-3.5.0  
export PATH=$M3_HOME/bin:$PATH 

Verify maven installation using mvn --v command
So the this is the same process  for installation of maven on Mac and Unix

  • Setup java/jdk 
  • Download Maven library and extract the local folder
  • Setup Environment variables
  • Verify using mvn –v command

Fix for  java.lang.OutOfMemoryError issue in maven

Maven compiles, copies, and runs the integration test using the maven installs command. If your project is large, there are too many objects in the heap memory, and this exception will be thrown if the heap memory cannot manage your project’s running object execution object size.

MAVEN_OPTS="-Xmx512m -Xms512m -XX:MaxPermSize=512m" 

Please share your comments on this.

Join 6,000 subscribers and get a daily digest of full stack tutorials delivered to your inbox directly.No spam ever. Unsubscribe any time.

Similar Posts
You'll get a notification every time a post gets published here.