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 6707359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:37:46+00:00 2026-05-26T07:37:46+00:00

In Eclipse, you can create a project jar with its required dependencies in an

  • 0

In Eclipse, you can create a project jar with its required dependencies in an adjacent sub-folder by doing …

  1. Export->Java->Runnable JAR file

  2. Select Library handling option: Copy required libraries into a sub-folder next to the generated JAR

Is there a way to do this with the Maven assembly plugin? Or is there another Maven plugin that would be more appropriate for this task?

Thanks!

  • 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-26T07:37:47+00:00Added an answer on May 26, 2026 at 7:37 am

    yes you can use assembly plugin.
    pom.xml:

    <build>
        <!-- final name set the jar name, if left it 
        will give defualt "${artifactId}-${version}" -->
        <finalName>jar final name</finalName>
        <sourceDirectory>src</sourceDirectory>
    
            <!-- compiler plug in -->
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <!-- assembly plugin -->
            <!-- the assembly plugin is used to define your 
            final deploy output (jar, zip, dir, war, etc..)-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <execution>
                        <id>assembly:package</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <!-- The filename of the assembled distribution 
                            file defualt ${project.build.finalName}-->
                            <finalName>${project.build.finalName}</finalName>
                            <appendAssemblyId>false</appendAssemblyId>
                            <!--    A list of descriptor files path to generate from-->
                            <descriptors>
                                <descriptor>assembly/assembly.xml</descriptor>
                            </descriptors>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- jar plug in -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>fully.qualified.MainClass</mainClass>
                            <!-- to create a class path to your 
                            dependecies you have to fill true in this field-->
                            <addClasspath>true</addClasspath>
                            <!-- if you put your dependencySet/outputDirectory 
                            in the assembly file is in a specific folder (lib for example), 
                            you need to add classpathPrefix-->
                            <classpathPrefix>lib/</classpathPrefix>
    
                            <!-- if you defined your dependencySet/outputFileNameMapping 
                            in the assembly, instead of using the classpathPrefix, 
                            you should use customClasspathLayout, 
                            add the classpathPrefix at the begining of the 
                            customClasspathLayout, and then add the pattern of the outputFileNameMapping, 
                            NOTICE YOU NEED TO ADD '$' BEFOR OF EACH '$'.
                            supported only from version 2.3>-->
                            <!--<classpathLayoutType>custom</classpathLayoutType>
                            <customClasspathLayout>
                                lib/$${artifact.groupId}.$${artifact.artifactId}.$${artifact.extension}
                            </customClasspathLayout>-->
    
                        </manifest>
    
                        <manifestEntries>
                            <Class-Path>conf/</Class-Path>
                        </manifestEntries>
                    </archive>
    
                </configuration>
            </plugin>
    
        </plugins>
    </build>
    

    assembly.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <assembly>
        <!--the id will be add to the end of the distribution file -->
        <id>package</id>
        <formats>
            <format>zip</format>
        </formats>
        <includeBaseDirectory>true</includeBaseDirectory>
    
    
        <fileSets>
            <fileSet>
                <directory>target</directory>
                <outputDirectory></outputDirectory>
                <includes>
                    <include>*.jar</include>                
                </includes>
            </fileSet>
            <fileSet>
                <directory>icons</directory>
                <outputDirectory>icons</outputDirectory>
                <includes>
                    <include>**/*</include>
                </includes>
            </fileSet>
            <fileSet>
                <directory>conf</directory>
                <outputDirectory>conf</outputDirectory>
                <includes>
                    <include>**/*</include>
                </includes>
            </fileSet>
        </fileSets>
    
        <files>
            <!-- you need to create the bat file yourself -->
            <file>
                <source>batFileName.bat</source>
                <filtered>true</filtered>
            </file>
        </files>
    
            <dependencySets>
                <dependencySet>
                    <!--define the outputDirectory of the dependencies, 
                        NOTICE: if it's diffrent from '/'  make sure to 
                        change the classPath configuration for 
                        the maven-jar-plugin in the pom-->
                    <outputDirectory>lib</outputDirectory>
                    <!-- maping the dependencies jar names.
                        NOTICE : if you used this definition, you need to use 
                        customClasspathLayout classPath configuration 
                        for the maven-jar-plugin in the pomg-->
                    <outputFileNameMapping>
                        ${artifact.groupId}.${artifact.artifactId}.${artifact.extension}
                    </outputFileNameMapping>
                    <unpack>false</unpack>
                </dependencySet>
            </dependencySets>
    
    </assembly>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I create a simple maven project in eclipse. Every time I create
I've created a view plug-in for Eclipse. I can export the jar from the
I tried to create a jar file from a java project, which uses some
I am new to eclipse + Java. I am trying to create executable jar
I have installed eclipse JDE plugin (ie BlackBerry_JDE_PluginFull_1.0.0.67.exe) , i can create a blackberry
i have created a java application which uses data from its config folder and
I have created a plugin project in eclipse to create a new category and
I need to create a jar file using eclipse IDE. But I am facing
I want to use this SDK, and I can not create project from existing
Can Maven create two jars specified in one pom.xml: one jar with my app

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.