Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7442487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:10:54+00:00 2026-05-29T11:10:54+00:00

I am trying to build an executable jar with maven-assembly-plugin with all the dependencies.

  • 0

I am trying to build an executable jar with maven-assembly-plugin with all the dependencies. I want the dependencies in a /lib/ directory inside the jar, with the main jar outside, and the configuration files in the same level of the main jar.

My pom.xml is:

<plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.2.1</version>
                <configuration>
                  <archive>
                    <manifest>
                      <addClasspath>true</addClasspath>
                      <classpathPrefix>lib/</classpathPrefix>
                      <mainClass>org.main.Class</mainClass>
                    </manifest>
                    <manifestEntries>
                        <Class-Path>/ MainClass.jar</Class-Path>
                    </manifestEntries>
                  </archive>
                  <descriptors>
                     <!--Relative path to your descriptor -->
                     <descriptor>src/main/assembly/packagejar.xml</descriptor>

                  </descriptors>
                </configuration>
</plugin>

The packagejar.xml is:

<id>eval</id>
  <formats>
    <format>jar</format>
  </formats>
  <includeBaseDirectory>false</includeBaseDirectory>
  <fileSets>
    <fileSet>
      <directory>${project.build.directory}</directory>
      <outputDirectory>/</outputDirectory>
      <includes>
        <include>MainClass.jar</include>
      </includes>
    </fileSet>
  </fileSets>
  <files>
    <file>
        <source>/src/main/resource/logging.properties</source>
        <outputDirectory>/</outputDirectory>
    </file>
    <file>
        <source>/src/main/resource/log4j.properties</source>
        <outputDirectory>/</outputDirectory>
    </file>
    <file>
        <source>/src/main/resource/hibernate.cfg.xml</source>
        <outputDirectory>/</outputDirectory>
    </file>
  </files>
  <dependencySets>
    <dependencySet>
      <outputDirectory>/lib/</outputDirectory>
      <useProjectArtifact>false</useProjectArtifact>
      <unpack>false</unpack>
      <scope>runtime</scope>
    </dependencySet>
  </dependencySets>
  </assembly>

And the resulting manifest.mf file is:

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: German
Build-Jdk: 1.6.0_22
Main-Class: org.main.Class
Class-Path: / MainClass.jar lib/dependency1.jar lib/dependency2.jar etc...

With this, I get the mainclass to execute, but it never finds the jars inside lib it needs to work. Probably I’m missing something basic. I’ve tried also adding in the pom.xml manifestEntries a lib/, lib/.jar, /lib and /lib/.

Any ideas?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T11:10:55+00:00Added an answer on May 29, 2026 at 11:10 am

    Refer Java Tutorial on why it can’t be done in the way you expect. For your question on the way to release an executable jar, that is one possible way, but not always you might want to send dependencies separately. There are couple of plugins that will build your executable jar with the dependencies in it(but not the way as you expected). look into OneJAR and Maven Shade . One JAR builts an executable jar with the dependencies in a lib directory , but has custom class loader classes within the executable jar. Maven shade plugin unjars the dependency libraries within the executable jar. I used Maven Shade, because I had the necessity to do some transformations when building the executable along with spring dependencies.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm trying to build an executable jar with dependencies for a spring project. my
I'm trying to make single executable *.jar via proguard plugin for sbt 10.*. All
I'm trying to build an executable jar from the command line (I don't want
I'm trying to use Maven to create an executable jar file that includes the
I'm trying to make an executable war file ( java -jar myWarFile.war ) that
I have been trying to build only the /libcore directory of the Android platform.
I am trying to build for debugging. I am getting the error: The executable
The error I'm getting: in /Users/robert/Documents/funWithFrameworks/build/Debug-iphonesimulator/funWithFrameworks.framework/funWithFrameworks, can't link with a main executable Cliff notes:
I am trying to build a very simple C++ program using the Maven NAR
Here is what I want to do: Typing make all will build my library

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.