Getting Started with Maven | Maven Quick Start | Creating and Running a Project
Create a simple Maven quick-start project and run the application.
Prerequisite
Maven must be installed. The installation article is listed in the Maven document index.
Maven: document list
Step 1: Create a Project
Create a project with the following command.
$ mvn archetype:generate -DgroupId=com.devkuma.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
The first run downloads various Maven resources.
Step 2: Check the Project
Confirm that the root directory my-app and the following resources have been created.
my-app/pom.xml
my-app/src/main/java/com/devkuma/app/App.java
my-app/src/test/java/com/devkuma/app/AppTest.java
pom.xml is the Maven project configuration file.
Step 3: Create and Run the Application Jar
Create the Jar file and run it with the following commands.
$ cd my-app
$ mvn package
$ java -cp target/my-app-1.0-SNAPSHOT.jar com.devkuma.app.App
Running the App class prints the following text.
Hello World!