chustar
chustar

Reputation: 12465

How do I create a standalone jar from a maven project?

I am trying to create a standalone jar file I don't think that maven package is properly packaging my dependencies into the package. Is there a way to force it to include them?

Upvotes: 6

Views: 5993

Answers (4)

Thanga
Thanga

Reputation: 8141

Please check this answer https://stackoverflow.com/a/35359756/5678086 for creating full pack with all dependencies

Upvotes: 0

db80
db80

Reputation: 4427

You can find an a basic example on how to use the maven assembly plugin here.

You need only to clone the repository

git clone git://github.com/db80/java-skeleton.git

and run mvn package

cd java-skeleton && mvn package

Upvotes: 0

Raghuram
Raghuram

Reputation: 52655

Alternately you could use the jar-with-dependencies packaging of maven assembly plugin.

Upvotes: 6

Gareth Davis
Gareth Davis

Reputation: 28069

You need to use the shade plugin.

By default maven builds and packages the compile output from the current project. The shade plugin allows to you create an 'uber' jar that contains not just your code but all of the dependencies into a single (sometimes quite big) jar.

Optionally allows you to relocate classes in the packaging phase, meaning that your project can have completely private copies of it's dependencies without getting caught in jar hell.

Upvotes: 4

Related Questions