First Maven Project

We will create first simple Maven project.


  • How to create simple maven project?
  • How to compile & package the project?

( 1 ) Generate Maven Project

  • Open windows command line
  • Go to the directory where you want to create your Maven project
  • In my case C:\Workspace\Maven_Projects>
  • Type mvn  archetype:generate
  • Press Enter
  • If it is your first time Maven will download some jars from remote repository on the Internet “you need to be connected”
  • All jars will be stored on your local .m2 repository  C:\Users\HMK\.m2 so next time Maven will take them from the local repository

  • Maven will list up number of archetypes and will show the default archetype number at the end of the list in this example it is 251.
  • Since it is the first project we will choose the default
  • Just press Enter

  • Choose version: Type 6
  • Press Enter
  • groupId: : com.hmkcode
  • artifactId : : FirstMaven
  • version: 1.0-SNAPSHOT : Press Enter
  • package: com.hmkcode: Press Enter
  • Type Y
  • Press Enter


Maven will generate src folder and pom.xml.

hmkcode folder contains one file, it simply prints Hello World!

( 2 ) Compile Maven Project

  • Change folder to the project folder
  • C:\Workspace\Maven_Projects\FirstMaven>mvn compile
  • Maven will crate target folder containing compiled classes

( 3 ) Package the Project “create jar file”

  • C:\Workspace\Maven_Projects\FirstMaven>mvn package
  • Maven will crate jar file “FirstMaven-1.0-SNAPSHOT.jar”  under target folder.