How to build a jar using Maven?

I want to build my project with Maven. How do I do that?

What must be entered in the command line to start building?

Upvotes: 3

Views: 7105

Answers (3)

Nicola Musatti
Nicola Musatti

Reputation: 18218

If your project is organized as Maven expects, e.g. your source code is in the src\main\java directory you can run

mvn package

to just build your jar

mvn install

to install it in your local Maven repository

mvn clean

to remove a previous build

Beware that you won't go very far with Maven without reading about it. You can start with this book.

Upvotes: 8

stacker
stacker

Reputation: 68942

In order to create an artifact (jar-file) you need to invoke

mvn package

This is very basic and you should take your time to read the suggested manuals before using maven.

Upvotes: 7

Andreas Dolk
Andreas Dolk

Reputation: 114757

Navigate to the folder that contains the pom.xml and enter

mvn package

(for a quick result)

Your machine needs to be connected to the internet as maven will download a lot of files from public repositories.

Upvotes: 6

Related Questions