[ Tutorial ] Maven – Install Maven and Create New Maven Project via Command Prompt

This tutorial covers how to install Maven and creating a Maven project.  At the time of this writing this entry (May 28, 2014) the stable version of maven is 3.2.1.

1. Download and Install Apache Maven

1.1. Download Maven

First things first: download maven (http://maven.apache.org/download.cgi)

Under the section that says This is the current stable version of Maven, click on “apache-maven-3.2.1-bin.zip”.  It will download a zip file that you will extract.  This needs to be installed manually.  What I prefer to do is create a folder called dev in a C drive (I’m using Windows 7), and inside that folder, I create another folder called tools.  This is where I extract all other tools.

1.2. Set up System Environment Variables

Next step is to set the environment variable for maven.  Open up ‘Computer’, then on top of the window, click on the button that says ‘System Properties’.


To the left is a link that says ‘Advanced System Settings’, it will bring a pop up window.


At the bottom right of the new pop up window, click on a button that says ‘Environment Variables…’ and that will bring another pop up window.


Under the System Variables section, we need to create a new variable; this tells your computer which directory to look at to run maven.  Click ‘New…’ and do the following:

Variable Name: MAVEN_HOME
Variable Value: C:\dev\tools\apache-maven-3.2.1 (Only if you extracted maven in the C:\dev\tools directory; different if you extracted it elsewhere)


Click OK.  Still under the System Variables section, scroll down until you find PATH variable, and click ‘Edit…’

Environment variables, such as PATH, can also have multiple values; each value needs to be separated by a semicolon. At the end of the Variable value, add a semicolon if there isn’t any, and type the following:


Please do not delete the variable value that was already set for the PATH variable. If you do, other programs dependent on that value might not work properly! If you’re doing it correctly, it should look something like this:


(WARNING: this does not check for the syntax.  So if you typed it wrong, your computer will not know where to look for to run maven!)

At this point, you are all set and ready to run maven and create a new maven project.  Click OK.

1.3. Test for Successful Installation

Now open up a command prompt (click start button, type in cmd and hit enter)

run the following command:

mvn -version

… and you should see the following:


if you do, you installed maven successfully.  Now let’s create a maven project.

2. Create New Maven Project

Creating a maven project is ridiculously easy.  Only thing I would worry about is to be careful when typing in the command correctly.

First off, use the cd (change directory) command to go to the directory where you will be creating a project.  What I prefer personally is to create it in C:\dev\workspace directory.  After you open up the command prompt, type in cd \dev\workspace or whichever directory you decide to work on.


Now type in the following command:

mvn archetype:generate -DgroupId=com.appname.app -DartifactId=app-name -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

and hit enter.  It should create a new project.  At the end, the command prompt will read BUILD SUCCESS.  Next step is to build the project package.  Change the directory to app-name (cd app-name) and type in the following command:

mvn package

and hit enter.  Again, at the end of it will read BUILD SUCCESS. At this point, you’re all set.  Thanks for reading, and happy developing.


One thought on “[ Tutorial ] Maven – Install Maven and Create New Maven Project via Command Prompt

  1. Pingback: [ Tutorial ] Maven – Connect to a ZooKeeper in Java | Inki's blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s