This blog talks about Installing Maven on Windows And Creating Maven project in Eclipse Juno
Maven is build and dependency management tool for java based application development, it is not install as windows service, rather is configured using windows environment variable.
In this post, I will summarize the steps need to install maven on windows operating system.
Step 1) Install java if not already installed
To install java download JDK installer from here and add/update JAVA_HOME variable
Go to control à system and security à system à advance system settings à advance tab à environment variables
Click on new under user variable give the variable name as JAVA_HOME and variable value path of JDK installation as shown below
Next go to system variable and select the path variable and click on edit button inset the JAVA_HOME variable created above go to end of the variable value and add ;%JAVA_HOME%\bin as shown below
Go to command line and check for class path whether is configured correctly or not. Type the java – version as show below
It will show the version of java if class path is configured. If not shows the version repeat step 1.
Step 2) Maven Installation
Download Maven and extract it location where you want. Maven can be download from here.
I extracted in D:\Maven-3.2.1 you can choose your own.
Now, set MAVEN_HOME variable just you did as JAVA_HOME variable as show below
Step 3) Test for Installation
Maven installation is complete. Now lets test it for windows command prompt go to start menu and type cmd in application location search box press ENTER. Command prompt will be open and type mvn –version and hit ENTER. It will shows the version information of maven installed. If there is any error cross check the step 2.
Creating Maven Project in Eclipse
Step 1) Installing maven eclipse plug-in
Open the eclipse IDE go to Help à Eclipse Marketplace
Eclipse marketplace window will open and search tab is activated by default search for maven. All maven related plug-in will be display click and install the Maven Integration for Eclipse WTP (Juno). If it is already installed it will shows the Update as shown below.
Step 2) Creating Maven Project
To create dynamic web project with maven, navigate to the folder where you want to store the project and supply following command:
D:\Users\Java-Project\maven-project>mvn archetype:generate -DgroupId=com.helical.maven.sample -DartifactId=SampleMavenProject -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
What is groupId in maven ?
groupId identifies a particular project uniquely across all projects, so we should follow an naming convention. A very simple and commonly used way of doing this is to use reverse of your domain, i.e. com.helical.maven.sample
A good way of maintaining the integrity of groupId is to use the project structure. In case the project is consists of multiple modules than every module should append an identifier to the parent groupId. i.e. com.helical.maven.sample, com.helical.maven.spring, com.helical.maven.struts .. etc.
What is artifactId in maven ?
artifactId is the name of war file without version, if you are creating it by yourself you are free to took any name of your choice in lower case and without any strange symbol. But if this is a third party jar than we have to take the name of jar as suggested by it’s distribution.
What is archetype in maven ?
Archetype is a Maven project templating toolkit which tells the maven the type of project we are going to create. Archetype enables the maven to create a template project of user’s choice so that the user can get the project up and running instantly.
“archetype:generate” generates a new project from provided archetype or update the actual project if using a partial archetype. Maven provides a number of predefined archtypes, see more details from Maven Documentation.
What is archetypeArtifactId in maven ?
While creating a new project we provide the archetypeArtifactId that informs maven about what archetype to use to create the initial structure of the project. Maven looks it up from the archetypeCatalog and works accordingly. e.g. If we want to create a simple web-app project we specify -DarchetypeArtifactId=maven-archetype-webapp.
Convert Maven project to support Eclipse IDE
Here we are done with creating a dynamic web project in maven, now lets make this project compatible to Eclipse IDE. To make maven project support eclipse ide navigate to project folder and supply following command :
D:\Users\Java-Project\maven-project \SampleMavenProjec>mvn eclipse:eclipse -Dwtpversion=2.0
Now import the maven project in eclipse as shown below.
Go to File import or right click import and select the Existing Maven Project click next
Browse to above created project directory and follows the steps and click on Finish.
Best Open Source Business Intelligence Software Helical Insight is Here