This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Ant, Maven and Other Build Tools and the fly likes [Ant] how to create a jar (not runnable) with other dependencies? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "[Ant] how to create a jar (not runnable) with other dependencies?" Watch "[Ant] how to create a jar (not runnable) with other dependencies?" New topic
Author

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

Rodrigo Soto
Greenhorn

Joined: Oct 13, 2009
Posts: 11
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.
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Jars typically don't have Jars inside their lib directories, they should simply live as themselves on the CLASSPATH.


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15950
    
  19

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Tim put it _far_ better than my lazy attempt, thanks Tim
 
 
subject: [Ant] how to create a jar (not runnable) with other dependencies?
 
Similar Threads
exception wile running build.xml
Path not working
Why can't run?
Building Seam projects in Eclipse
problem in making jar and war based on the 'src' package hierarchy!