Maven Tutorial – 3

Lets create a simple application as we have seen in Tutorial -2.

Execute the following command. Ensure you have jdk bin and maven bin folders in path!

$ mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DartifactId=my-app

We are generating a simple project based on generate architype – a simple template. After issuing the above command, you will see a list of lines and characters are running on the screen. You will be asked some questions, just press enter!


You can see a new folder is created with your artifact id, which is ‘my-app’ here! If you browse through this folder, you will see the following.

$ ls
$ cd my-app/
$ ls
pom.xml src
$ cd src
$ ls
main test
$ cd main
$ ls
$ cd java
$ ls
$ cd org/grassfield/app/
$ ls – Created by Maven


Lets modify it now.

Here it is!


Lets see what’s written inside pom.xml

pandian@pandian-SH560:~/pandian/my-app$ cat pom.xml
<project xmlns="" xmlns:xsi=""





POM refers to junit alone as its dependency!

Now lets compile it.

$ mvn compile



Lets test it now! The following is the maven test case.


$ mvn test


Lets package it now!

$ mvn package


Console is interesting. But you love Eclipse IDE like, right? Lets create the Eclipse project structure for this artifact.

$ mvn eclipse:eclipse


Now import the java project from the location highlighted above.

maven10 - Eclipse IDE

Lets see how to work with Eclipse using Maven in my next post.

Related posts:

Maven – 1

Maven – 2

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s