Databases

Kodejava

Tag Archives: Windows

In this post you will learn about Apache Maven. What is Maven? In simple words, Maven is a tool that we can use to build and manage a Java based project. Compare to the older type of build tool such as Ant, which is also an Apache project, Maven gives developers a standard way to build projects, a clear definition of the projects consisted of, an easy way to publish project information and an easy management of the project libraries dependency.

In Maven, the project libraries (Jars) will be maintained in the Maven repository and can be shared among projects. We don’t need to include the Jars in the project’s source code, as what we usually do when using tool like Ant. And here are the main objectives of the Apache Maven project:

Making the build process easy.

Providing a uniform build system.

Providing quality project information.

Providing guidelines for best practices development.

Allowing transparent migration to a new features.

After you know a little bit about Maven, let’s continue to the next step, installing the Apache Maven.

Step 1. Downloading Apache Maven

Go to Apache Maven and from the Get Maven section on the left sidebar click Download link.

Download the appropriate installer for your platform. For example I am downloading the .zip file. The latest version when this post is written is Maven 3.1.0 (apache-maven-3.1.0-bin.zip).

Extract the downloaded zip file. For example I am extracting it into D:\Toolbox\apache-maven-3.1.0 directory.

Step 2. Configuring Environment Variables

After extracting Maven distribution you have to define M2_HOME environment variable. The value of this variable is the path to your Maven installation.

You can create environment variable using the following steps:

Right click on My Computer.

Select Properties menu.

Select Advanced system settings.

In the System Properties window select the Advanced tab and click the Environment Variables button.

Add the variable in the System variables section.

Click OK to proceed.

Add the %M2_HOME%\bin; into your PATH environment variable so that you can execute Maven command from any path inside your command prompt. This PATH variable can also be updated in the System variables section.

Open your command prompt and type echo %M2_HOME%. Pressing Enter and you should see the value of the variable printed on the console. For example:

D:\>echo %M2_HOME%
D:\Toolbox\apache-maven-3.1.0

To check if Maven also in your Path variable you can execute echo %PATH% in your command prompt. You should see the path to Maven binary in the Path variable.