What is Maven and how do I install it?
Author: Deron Eriksson
Description: This tutorial demonstrates how to install Maven 2.
Tutorial created using: Windows Vista || JDK 1.6.0_04 || Eclipse Web Tools Platform 2.0.1 (Eclipse 3.3.1)

Page:    1 2 >

MavenSW, located at http://maven.apache.org, is a great JavaSW project build and management tool from the ApacheSW Software Foundation. One primary focus of Maven is as a build tool, performing tasks similar to AntSW, although it's more like Ant on steroids.

A very significant aspect of Maven is the use of repositories to manage jarW files across different projects. In a simple software development environment, you may work on a project and check jar files directly into your project in your version control system, and you may do this in each project that you work on. This system works fine in relatively simple situations, but it becomes unweildy as projects grow in size, in complexity, and in their numbers of developers. In the Maven system, jar files are stored in remote repositories, and they are downloaded to your local machine to a local repository as needed. Typically, these same jar files are accessed across projects, and Maven makes it very simple to manage different versions of jar files, and to group together sets of related jar files. Building different types of projects (such as jars, wars, and ears) is handled very cleanly by Maven. Maven can perform tasks such as generate useful documentation about your project. The features of Maven go on and on.

Maven 2 is very significantly different from Maven 1. This tutorial will cover Maven 2.

To set up Maven, you need to:

  1. Download Maven and unzip it
  2. Create a JAVA_HOME System Variable
  3. Create an M2_HOME System Variable
  4. Add %JAVA_HOME%\bin;%M2_HOME%\bin; to your System Path

To begin with, download the latest Maven from http://maven.apache.org/download.html. I downloaded apache-maven-2.0.8-bin.zip and extracted it to C:\dev\apache-maven-2.0.8.

apache-maven-2.0.8-bin.zip extracted to C:\dev\apache-maven-2.0.8

Go to your System Properties → Environment Variables.

Environment Variables

Create a JAVA_HOME System Variable and point it to your Java installation. I pointed mine to C:\dev\jdk1.6.0_04.

JAVA_HOME System Variable

Create an M2_HOME System Variable and point it to your Maven installation. I pointed mine to C:\dev\apache-maven-2.0.8.

M2_HOME System Variable

You should now have JAVA_HOME and M2_HOME System Variables.

System Variables

Add %JAVA_HOME%\bin;%M2_HOME%\bin; to your Path System Variable. This puts your Java and Maven executables in the System Path so that they can be executed without their fully qualified paths.

Adding %JAVA_HOME%\bin;%M2_HOME%\bin; to Path System Variable

(Continued on page 2)

Page:    1 2 >