You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by josh <jo...@speakeasy.net> on 2003/05/24 00:32:38 UTC

Class-Path, Manifest.mf and Me

Hi Everyone!

I saw a neat trick in the Batik source where they have a single 
batik.jar that contains nothing but a Manifest.mf file that adds the 
other 7000 or so batik jars to the classpath.  So I decided to try it 
myself, for the reduced number of jars I needed in my application:

<target name="batik-jar">
   <jar destfile="${lib}/batik/mybatik.jar">
     <manifest>
       <attribute name="Class-Path" value="batik-ext.jar batik-dom.jar 
batik-css.jar batik-svg-dom.jar batik-gvt.jar batik-parser.jar [full 
list trimmed]"/>
     </manifest>
   </jar>
</target>

The ant task runs fine, and gets me a jar with only a Manifest.mf 
inside, with these contents:

Manifest-Version: 1.0
Class-Path: batik-ext.jar batik-dom.jar batik-css.jar batik-svg-dom.ja
  r batik-gvt.jar batik-parser.jar batik-script.jar batik-bridge.jar ba
  //etc


Ok, the problem is that it doesn't work.  None of the classes in the 
jars listed in the manifest are found.  When I add 'mybatik.jar' to my 
classpath and recompile, everything barfs.

Any idea what I'm doing wrong?

- josh


Re: Class-Path, Manifest.mf and Me

Posted by josh <jo...@speakeasy.net>.
webhiker@tiscali.fr wrote:
> AFAIK the class-path attribute only applies to when you execute a file 
> using the "java -jar <jar-file>"
> These jars need to be placed relative to the jar you are executing. For 
> packaging purposes I find it neater to use
> <attribute name="Class-Path" value="lib/myjar.jar"/>
> 
> and copy all the jars into a lib directory in the same directory as my 
> jar file.
> 
> Ant will probably (and rightly) ignore this attribute if the jar is 
> included in a classpath.
> 
> WH

That seems to be the case, although it's sort of a shame.  Does anyone 
know of any documentation that specifically says this?

> 
>> Hi Everyone!
>>
>> I saw a neat trick in the Batik source where they have a single 
>> batik.jar that contains nothing but a Manifest.mf file that adds the 
>> other 7000 or so batik jars to the classpath.  So I decided to try it 
>> myself, for the reduced number of jars I needed in my application:
>>
>> <target name="batik-jar">
>>   <jar destfile="${lib}/batik/mybatik.jar">
>>     <manifest>
>>       <attribute name="Class-Path" value="batik-ext.jar batik-dom.jar 
>> batik-css.jar batik-svg-dom.jar batik-gvt.jar batik-parser.jar [full 
>> list trimmed]"/>
>>     </manifest>
>>   </jar>
>> </target>
>>
>> The ant task runs fine, and gets me a jar with only a Manifest.mf 
>> inside, with these contents:
>>
>> Manifest-Version: 1.0
>> Class-Path: batik-ext.jar batik-dom.jar batik-css.jar batik-svg-dom.ja
>>  r batik-gvt.jar batik-parser.jar batik-script.jar batik-bridge.jar ba
>>  //etc
>>
>>
>> Ok, the problem is that it doesn't work.  None of the classes in the 
>> jars listed in the manifest are found.  When I add 'mybatik.jar' to my 
>> classpath and recompile, everything barfs.
>>
>> Any idea what I'm doing wrong?
>>
>> - josh


Re: Class-Path, Manifest.mf and Me

Posted by "webhiker@tiscali.fr" <we...@tiscali.fr>.
AFAIK the class-path attribute only applies to when you execute a file 
using the "java -jar <jar-file>"
These jars need to be placed relative to the jar you are executing. For 
packaging purposes I find it neater to use
<attribute name="Class-Path" value="lib/myjar.jar"/>

and copy all the jars into a lib directory in the same directory as my 
jar file.

Ant will probably (and rightly) ignore this attribute if the jar is 
included in a classpath.

WH

> Hi Everyone!
>
> I saw a neat trick in the Batik source where they have a single 
> batik.jar that contains nothing but a Manifest.mf file that adds the 
> other 7000 or so batik jars to the classpath.  So I decided to try it 
> myself, for the reduced number of jars I needed in my application:
>
> <target name="batik-jar">
>   <jar destfile="${lib}/batik/mybatik.jar">
>     <manifest>
>       <attribute name="Class-Path" value="batik-ext.jar batik-dom.jar 
> batik-css.jar batik-svg-dom.jar batik-gvt.jar batik-parser.jar [full 
> list trimmed]"/>
>     </manifest>
>   </jar>
> </target>
>
> The ant task runs fine, and gets me a jar with only a Manifest.mf 
> inside, with these contents:
>
> Manifest-Version: 1.0
> Class-Path: batik-ext.jar batik-dom.jar batik-css.jar batik-svg-dom.ja
>  r batik-gvt.jar batik-parser.jar batik-script.jar batik-bridge.jar ba
>  //etc
>
>
> Ok, the problem is that it doesn't work.  None of the classes in the 
> jars listed in the manifest are found.  When I add 'mybatik.jar' to my 
> classpath and recompile, everything barfs.
>
> Any idea what I'm doing wrong?
>
> - josh
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>