Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include maven dependencies in a jar file? [duplicate]

I have an eclipse Luna project with a bunch of maven dependencies defined in a pom.xml

Everything works fine in eclipse. But now I need to include all of those dependencies in an exportable jar file (so that I can ship them to workers in Apache Spark).

I keep fiddling with the export settings, but I don't see any way to export them into the jar file.

enter image description here

I find some answers explaining how to configure maven to package its dependencies. Is that my only option, or is there some way to do this in eclipse?

like image 639
bernie2436 Avatar asked Feb 05 '15 01:02

bernie2436


2 Answers

Take a look at this question: How can I create an executable JAR with dependencies using Maven?

I think that @Rocky Inde's answer is what you are looking for (using eclipse):

1) Just right-click on your project folder (in Eclipse) and select Export

2) Then select Java -> Runnable Jar

3) You will be asked to choose the location of the jar file

4) Finally, select the class that has the Main method that you want to run and choose Package dependencies with the Jar file and click Finish

like image 183
Tarik Avatar answered Nov 18 '22 23:11

Tarik


Then you need to include shade pluggin in your pom.xml and mvn package will produce the shade jar(fat jar) this link provides info about shade pluggin

like image 22
kasinavijay Avatar answered Nov 19 '22 00:11

kasinavijay