• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Jars within Jar  RSS feed

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
I have written a custom ant task and have made a jar and placed it in Ant's lib directory. The jar file has some dependencies which are jar files them selves (jdom.jar,commons-lang.jar and javagit.jar to be exact). It also has a dependency on ant.jar but I have not included that in the application's jar file.When I execute the custom ant task, I get an error "ClassNotFoundException" for classes that are being used in the Custom Ant Task class (except for Classes in ant.jar).When I extract the dependencies and then create a jar file (no jars within the jar file), it works fine !

Here is the METAINF file when the dependencies are extracted
Manifest-Version: 1.0

Ant-Version: Apache Ant 1.7.1

Created-By: 11.0-b15 (Sun Microsystems Inc.)

Class-Path: . (in case of jars --> jdom.jar javagit.jar commons-lang.jar)

1. How come I am not getting any errors for classes in ant.jar ?
2. Can any one kindly explain why the JRE can't find the files from with in the dependencies as jar files as opposed to dependencies as extracted files ?
3. Is there a way to create a jar file with dependencies as jar files and how to configure it so that the runtime can find the files from within the jar files ?

Waiting for a favorable response.

Kind Regards.
 
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

1- since ant.jar is nested it works.

2- Nested Jars are not loaded by default class loader. i.e. nested jar files are not supported.

3- There are some other tools (try google) that make it possible, but by default it does not work. If you want a single Jar, one option is to unjar all the jar files and create a single jar from the class files.
 
Hasnain Javed Khan
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thank you so much for your kind response.
I'll search it on google.
Kind Regards.
Hasnain
 
When you have exhausted all possibilities, remember this: you haven't - Edison. Tiny ad:
ScroogeXHTML - small and flexible RTF to HTML converter library
https://coderanch.com/t/710903/ScroogeXHTML-RTF-HTML-XHTML-converter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!