Maven: Getting started

2024-05-03 #dev #tools #post

Install maven

sudo apt install maven

Create a new project

mvn archetype:generate\\

cd app/

Set compiler release

Open the pom.xml file and update the following lines:

<!-- E.g., 11, 17, 21, etc. -->

Add dependencies

Add the following sample dependency to the pom.xml file:


Package and run

mvn package
java -cp target/app-1.0-SNAPSHOT.jar

You might also like maven-generate-self-contained-jar.