I am going to create very simple project with Maven so that you can undestand the folder structure and Project Object Model used by the Maven
First you should have installed the Maven in your computer. If you have not done it already you can refer this article.
You can open up the terminal and chnage the directory where you want to create the project. Then you can issue the following command
mvn archetype:generate -DgroupId=com.codekayak -DartifactId=helloworld -DarcheTypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
The artifactId
parameter specifies the directory name to use as the base directory for the project.In this example it is helloworld
The groupId
is the package name
Once inststalled, you can go the project folder and browse the folder structure of the project
This is the pom.xml file what you find in the root of the project
4.0.0 com.codekayak helloworld jar 1.0-SNAPSHOT helloworld http://maven.apache.org junit junit 3.8.1 test
You can see the full POM file by issuing the following command in your terminal. You should change directory in your terminal to “helloworld”
mvn help:effective-pom
How to run the application
Now you can build the project using following command
mvn install
Now you can see the .jar file inside the build folder
You can issue the following command to run the project
java -cp target/helloworld-1.0-SNAPSHOT.jar com.codekayak.App