Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

jar Problem with Class-Path

1 view
Skip to first unread message

Roland Geier

unread,
Apr 23, 2001, 4:41:36 AM4/23/01
to
Hi there,

I'm using the Class-Path header field in a jar file named 'Appl.jar' to
reference other jar files required by an application running under NT4.0.
All jar files are located beneath a directory <anywhere>/lib and various
subdirectories.

The Manifest for '<anywhere>/lib /Appl.jar' looks like:

------------- cut here -------------
Manifest-Version: 1.0
Created-By: 1.3.0_02 (Sun Microsystems Inc.)
Class-Path: subdir1/packageA.jar
Class-Path: subdir2/packageB.jar
:
:
Class-Path: subdir9/packageY.jar
Class-Path: subdir9/packageZ.jar
------------- cut here -------------

Please assume that there are arbitrary dependencies between any of these
packages. All those packages listed in the Class-Path statements do *not*
have any Class-Path entries in their own manifest files.

When I start my Application by calling

java -cp <anywhere>/lib/Appl.jar Main

only the very last Class-Path in the manifest seems to be recognized by the
class loader. That means, package 'subdir9/packageZ.jar' can be located by
the class loader, all the other packages cannot but trigger a
NoClassDefFoundError exception instead.

Isn't it enough to put all referenced jar-files of an application into the
manifest of a single jar?

Thx for any hints,

--
Roland.


Lucio Benfante

unread,
Apr 23, 2001, 6:14:05 AM4/23/01
to
>===== Original Message From "Roland Geier" <roland...@gmx.de> =====

Hi,
I'm not sure, but I think you have to use a single Class-Path header, with
multiple space-separated paths.
For example:

Class-Path: subdir1/packageA.jar subdir2/packageB.jar ...
subdir9/packageY.jar
subdir9/packageZ.jar

Best regards
Lucio

-----------------------------------------
Lucio Benfante (benf...@MailandNews.com)
Brainbench MVP for Java 1
http://www.brainbench.com

Roland Geier

unread,
Apr 23, 2001, 6:27:52 AM4/23/01
to
Hi Lucio,

> I'm not sure, but I think you have to use a single Class-Path header, with
> multiple space-separated paths.

Indeed that works - given that the single line doesn't get too long for the
jar tool. Otherwise the jar tool fails:

java.io.IOException: line too long
at java.util.jar.Attributes.read(Attributes.java:336)
at java.util.jar.Manifest.read(Manifest.java:161)
at java.util.jar.Manifest.<init>(Manifest.java:56)
at sun.tools.jar.Main.run(Main.java:125)
at sun.tools.jar.Main.main(Main.java:904)

BTW, multiple Class-Path heades should work according to
http://java.sun.com/j2se/1.3/docs/guide/extensions/spec.html:

: Multiple Class-Path headers may be specified, and are combined
sequentially.

--
Roland.


0 new messages