Install and configure maven Tutorials

Maven is a build tool to automate the build process of java based projects.Java development environment is required for maven installation on any platform. Before installing maven, Please make sure that you installed latest JDK version

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 will be displays the maven version and the java version. The following is the screenshot attached for this command

Install, configure Maven in windows

Install and setup Maven on Linux

Please download the latest maven from maven official site. apache-maven-3.5.0-bin.tar.gz downloaded it to your local folder. Extract and copy to a location usr/local/apache-maven-3.5.0 and configure 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:-

using maven install command, Maven compiles, copy and execute the integration test. if your project is big, then there are too many objects in the heap memory, if the heap memory is not accommodating your project running object execution size, this exception will be thrown.

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

Please share your comments on this.

Similar Posts