• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Using Ant Javac to recognize jars in jars

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to use Ant to compile some java files which are dependant upon classes held in a jar file. This jar file is in another jar file.
Two questions:
Can I put a jar file in a jar file?
If so, How can I get the Ant javac task to recognize the inner jar so my import statements found in my java file will not give me a compile error?
Thanks
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Stolen from Sun's forum:
There is a line in the manifest which you can use to add JARs to the CLASSPATH. The paths are relative so the line:
Class-Path: jaxp.jar parser.jar
expects to find these JARs in the same directory as the main jar file.
 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think if you need to have a jar actually inside another jar, you are going to have to extract it manually.
Or, if you're looking for a "fun" project, you could write your own "JarInJarClassLoader"
Note that if you use the Class-Path entry in the jar manifest, there is a bug with javac(and javap) - they do not recognize it and you have to put all those jars in classpath for compiling.
The java command (jvm) does recognize manfiest Class-Path entries as it should.
 
Kevin Crocker
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Am I to assume that you mean the javac (compiler) and not a bug with ANT and the javac task?
 
Dave Landers
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Right.
http://developer.java.sun.com/developer/bugParade/bugs/4212732.html
[ September 09, 2002: Message edited by: Dave Landers ]
 
sunglasses are a type of coolness prosthetic. Check out the sunglasses on this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic