Java | Maven | How to pack Maven dependencies while creating jar file

| By Webner

We were creating a Maven project having packaging type jar. We had main class from where we were starting project execution. It was working fine through Eclipse but when we created jar file by compiling with Maven, we were not able to run the jar as it was throwing missing dependencies errors.


Maven provides a plugin named Maven-assembly-plugin which is used to pack all dependencies while creating jar file.

Add plugin in section in the pom file as given below:

<mainClass>main class path here</mainClass>
<id>make-assembly</id> <!-- this is used for inheritance merges ->
<phase>package</phase> <!-- bind to the packaging phase -->

After adding this plugin, it packs all required libraries (declared inside pom.xml file) in the final jar file.

Webner Solutions is a Software Development company focused on developing CRM apps (Salesforce, Zoho), LMS Apps (Moodle/Totara), Websites and Mobile apps. If you need Web development or any other software development assistance please contact us at

Leave a Reply

Your email address will not be published. Required fields are marked *