0- prerequest : you must have Java installed in order to proceed.
1- download and install maven
2- make sure you installed by showing the version and other info of it: mvn --version
3- Creating a Project:
mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
4- cd my-app
5- you will see standard project structure there:
my-app
|-- pom.xml
`-- src
|-- main
| `-- java
| `-- com
| `-- mycompany
| `-- app
| `-- App.java
`-- test
`-- java
`-- com
`-- mycompany
`-- app
`-- AppTest.java
6. The POM
The pom.xml file is the core of a project's configuration in Maven.
It is a single configuration file that contains the majority of information required to build a project
Example:
4.0.0
com.mycompany.app
my-app
1.0-SNAPSHOT
1.8
1.8
junit
junit
4.12
test
7. Build the Project
mvn package
8. test the newly compiled and packaged JAR with the following command:
java -cp target/my-app-1.0-SNAPSHOT.jar com.mycompany.app.App
Which will print the quintessential:
Hello World!