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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:02:16+00:00 2026-05-31T06:02:16+00:00

I want to create a jar with the following directory structure: thejar.jar/ classes/ –>

  • 0

I want to create a jar with the following directory structure:

thejar.jar/
    classes/ --> where all classes go
    lib/ --> where all dependencies go
    res/ --> where all non-classpath resources go (scripts, etc.)
    META-INF/

Here’s my ant task:

<jar destfile="dist/main/thejar.jar">
    <!-- Create the manifest -->
    <manifest>
        <!-- JAR should be sealed. -->
        <attribute name="Sealed" value="true" />
    </manifest>

    <!-- Copy main build directory to classes/ directory in JAR. -->
    <fileset dir="dist/main/classes" includes="build/main"/>

    <!-- Copy main library directory to lib/ directory in JAR. -->
    <fileset dir="dist/main/lib" includes="lib/main"/>

    <!-- Copy main resources directory to res/ in JAR. -->
    <fileset dir="dist/main/res" includes="res/main"/>
</jar>

If I am understanding this correctly, it should be:

  • Copying all the built (.class) files in build/main to dist/main/classes
  • Copying all lib/main dependencies to dist/main/lib
  • Copying all res/main files to dist/main/res
  • JARring up dist/main/* into thejar.jar

The JAR task executes without errors, but when I go to view the contents of thejar.jar I just see META-INF/ (none of the subdirectories I mentioned above).

What’s going on here? 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-31T06:02:17+00:00Added an answer on May 31, 2026 at 6:02 am

    You want jar task to copy files in build/main into jar’s dist/main/lib, but

    <fileset dir="dist/main/classes" includes="build/main"/>
    

    means to pack files in dist/main/classes/build/main into the jar file.

    Take a look at the example from the Ant-Jar task doc:

    <jar destfile="${dist}/lib/app.jar">
        <fileset dir="${build}/classes"
                 excludes="**/Test.class"
        />
        <fileset dir="${src}/resources"/>
    </jar>
    

    (The code above) jars all files in the ${build}/classes directory and also in the ${src}/resources directory together into a file called app.jar in the ${dist}/lib directory.

    To achieve your request, I think you can copy the classes, resources and dependencies with <copy> task into the directory structure that you want and then jar the directory.

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

Sidebar

Related Questions

I have the following folder structure: project.ear lib folder ProjectEJBClient.jar META-INF folder projectEJB.jar My
I want to create a jar file with my own classes. Can anyone give
I'm new to Scala and don't know Java. I want to create a jar
I want to create registry key through java program to add the jar file
I want to create a file in the current directory (where the executable is
I want to create a runnable JAR that include referenced libraries, namely jackson ,
The folder Test contains various files and folders. I want to create a jar
I want to create a jar file of a Java project, which compiles. I've
I want to create a jar file containing downloaded and processed Internet files. And
I want create a excel with Apache POI in java and I must insert

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.