• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

[Ant] how to create a jar (not runnable) with other dependencies?

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I am trying to build a jar file as an API for other applications to use. The problem is that when I try to use API.jar it relies on other jars that I've included inside API.jar but it the JVM does not find the dependencies. Here is my build.xml:

This creates a jar file with the following tree:
api------
|
com(where some src classes are)
|
net (some other src classes are)
|
conf(configuration files for com and net classes)
|
lib (where dependencies are placed)
|
Meta-Inf
And when I the main application uses API.jar the following error is thrown:


Thank you.
 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jars typically don't have Jars inside their lib directories, they should simply live as themselves on the CLASSPATH.
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JVM's won't find the dependencies. The standard classpath architecture for JVM's doesn't include looking inside JARs for other JARs. To do that you have to provide your app with a custom classloader. It's what the webservers do in order to resolve the resources inside the WEB-INF/libs directory, for example.
 
Martijn Verburg
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tim put it _far_ better than my lazy attempt, thanks Tim
reply
    Bookmark Topic Watch Topic
  • New Topic