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

  • Home
  • SEARCH
  • 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 6889845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:12:26+00:00 2026-05-27T06:12:26+00:00

I have a java project with class having main method in package com.nik.mypackage. Only

  • 0

I have a java project with class having main method in package com.nik.mypackage. Only one library is referenced which is someLib-5.0.2.jar

This library is in lib folder in eclipse and added to the build path.

I am creating executable jar of the application using the below ant script target:

 <property name="src" location="src"/>
 <property name="build" location="build"/>
 <property name="dist"  location="dist"/>

   <target name="init">
      <tstamp/>
      <mkdir dir="${build}"/>
   </target>


 <target name="compile" depends="init"
    description="compile the source " >
       <javac srcdir="${src}" destdir="${build}">
       <classpath>
         <pathelement path="${classpath}"/>
              <pathelement location="lib/someLib-5.0.2.jar"/>
        </classpath>
       </javac>
   </target>

<target name="dist" depends="compile" description="generate the distribution" >
   <!-- Create the distribution directory -->
   <mkdir dir="${dist}/lib"/>
<copy todir="${build}/lib" verbose="true" file="lib/someLib-5.0.2.jar" />

       <!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->
       <jar jarfile="${dist}/lib/myProject-${DSTAMP}.jar" basedir="${build}">

       <manifest>
            <attribute name="Main-Class" value="com.nik.mypackage.MainClass"/>
            <attribute name="Class-Path" value="../lib/someLib.jar"/>
       </manifest>
</jar>
</target>

The jar MyProject-20111126.jar is getting created. However, running the below command:

c:>java -jar MyProject-20111126.jar

is throwing a NoClassDefFoundError for a class in someLib.jar

What am I doing wrong ??

Thanks for reading!

  • 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-27T06:12:26+00:00Added an answer on May 27, 2026 at 6:12 am

    As mentioned in the comment by Eric Rosenberg, we can not nest jar files inside other jar files. So we need to deflat the library and bundle individual classes in the app jar.

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

Sidebar

Related Questions

I have a Java project in Eclipse with class MainClass having main method in
I have a Java project in Eclipse with ~10 packages and ~10 class files
I have been working on a Java project for a class for a while
I have a java project in which I have Referenced Libraries. In the Referenced
I'm doing another Java project for my class. In this assignment, we have to
I'm having issues with a java class project. The first step consist in drawing
I have an Android project which included a class with a file copy method.
I have some experience writing web applications in Java for class projects. My first
I have a Java project that needs a addon interface. I was thinking about
I have a Java project connecting to an Ingres database and using the Spring

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.