Maven Setup and Installation on Windows

Maven

Maven Setup and Installation on Windows OS

Maven is a build automation tool used primarily for Java projects, so you must have Java installed in order to proceed.

Prerequisites :-

JDK must be installed and “JAVA_HOME” variable should be added as a Windows environment variable. (Link to Install and setup Java )

Download Maven:-

Link to Download Maven

1

After successful download, unzip to the downloaded folder at your desired location. e.g.  C:\apache-maven-3.3.3

How to setup Maven environment variables and their path?

Go to Control Panel\All Control Panel Items\System –> Click on Advance System Settings –> Click on Environment Variables

Go to System Variables –> Click on New

Add M2 HOME and MAVEN HOME:-

  1. M2_HOME: C:\apache-maven-3.3.3

    M2Home

  2. MAVEN_HOME: C:\apache-maven-3.3.3

    MAven Home1

Add to Path:-

Update Path variable in Environment Variables

In path variable put   “C:\apache-maven-3.3.3\bin;

Verify Maven Installation:-

Open Command Prompt and type mvn -version command and it will display the installed maven into your system.

mvn –version

Maven Version

*********************************************************************************

Steps to Compile, Clean and Run Maven Project using Command Prompt

The command to Clean Maven Project:-

mvn clean

mvn Clean

Command to Compile Maven Project:-

mvn compile
Mvn Compile

Command to Run Maven Project:-

mvn test
mvn test

Command to Run Maven Project using Parameters:-

mvn test -Denv = QA -Dver=v12

  mvn parameters 
**********************************************************************************

How to install Maven Plugin in Eclipse?

Steps:-

  • Launch Eclipse IDE
  • Click  on Help
  • Click on Install New Software
  • Click Add button at top right corner
  • Enter “Add Repository Name” as “Maven
  • Enter “Location” as http://download.eclipse.org/technology/m2e/releasese2
  • Click on OK
  • It will download Maven Integration PluginMaven e 3
  • Click on Select All and click on Next
  • Accept License and Click on Finish
  • Restart Eclipse

After successful installation performs the followings steps in Eclipse:-

  1. Go to Window –> Preferences
  2. Observe, Maven is enlisted at left panel

Convert Java Project into Maven:-

  1. Click on an existing project
  2. Select Configure -> Convert to Maven Project

 

 

 

 

2 thoughts on “Maven Setup and Installation on Windows

Leave a Reply

Your email address will not be published. Required fields are marked *