How to Configure Maven in Window and Linux?


Configuration in Maven  in Window and Linux required below steps.

  • Download latest version of maven from below link

Download Link : http://maven.apache.org/

Configuration in Window

  • Unzip file apache-maven-X.X.X-bin.zip and change unzip file name like name as maven. It will have directory structure like below
  • window maven directory

    Maven Directory Structure

  • Copy this maven folder to C:\Program Files (x86) directory.
  • Add below Environment Variable by right click on My Computer -> Properties-> Environment Variable/Advance System Settings
    User Environment Variable
    
    M2_HOME : C:\Program Files (x86)\maven
    M2: %M2_HOME%\bin
    PATH : %M2%;
    
    If you already have any value in PATH add %M2%;   after end of value.
    

    It will show as below in screen shot

    maven environment variable window

  • Close all console instances/Command prompt if running and open new command prompt and run below command and will receive output with version of Maven and Java.
    mvn –-version 
    
    C:\Users\FacingIssuesOnIT>mvn --version
    Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T11:41:47-05:00)
    Maven home: C:\Program Files (x86)\maven
    Java version: 1.8.0_73, vendor: Oracle Corporation
    Java home: C:\Program Files\Java\jdk1.8.0_73\jre
    Default locale: en_US, platform encoding: Cp1252
    OS name: "windows 7", version: "6.1", arch: "amd64", family: "dos"
    

Configure in Linux

Download latest version of Maven and Untar it with below command

tar -zxvf  apache-maven-3.5.0-bin.tar.gz

change name of directory as apache-maven-3.5.0 and set maven environment variable as below for configuration

$ export M2_HOME=/opt/app/facingissuesonit/apache-maven-3.5.0

$ export M2=$M2_HOME/bin
Set below for memory configuration
$ export MAVEN_OPTS=-Xms256m -Xmx512m
with M2_Home path corresponding with the location of your extracted Maven files.

Now append the M2 environment variable to the system path as below:

$ export PATH=$M2:$PATH

To check maven install successfully follow below command

mvn --version

Apache Maven 3.5.0 (r801777; 2009-08-06 15:16:01-0400)
Java version: 1.8.0_73
Java home: /opt/app/facingissuesonit/posbea/jdk-1.8.0_73/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux" version: "2.6.32-642.6.2.el6.x86_64" arch: "i386" Family: "unix"

 

About Saurabh Gupta

My Name is Saurabh Gupta, I have approx. 10 Year of experience in Information Technology World manly in Java/J2EE. During this time I have worked with multiple organization with different client, so many technology, frameworks etc.
This entry was posted in Java, Maven and tagged , , , . Bookmark the permalink.