Jar manifests, the bane of all Java developers. Why weren't regular properties files sufficient?
My jar required two additional linked library jars in its class path, so I added them into the ant build script which I use to create the jar. Suddenly my application stopped working. After some confusion, I opened up the jar manifest file and saw that the class path line was cut off in the middle of one of the jar names! I tried several ways to break the line between jar names, but none of them worked.
Ant's FAQ is positively rude on the issue. It reads
Ant implements the Java Jar file specification. Please refer to the notes section where it discusses the maximum allowable length of a line and the concept of continuation characters.
That is completely unhelpful, because the Jar file specification says
No line may be longer than 72 bytes (not characters), in its UTF8-encoded form. If a value would make the initial line longer than this, it should be continued on extra lines (each starting with a single SPACE).
and the ant FAQ doesn't explain how to create such a continued line in a manifest file!
Then check this out: Bug ID: 4482804 Class-Path mangled in Manifest. It says:
If you do not want to have long lines , you could also do it like this
Created-By: 1.3.1 (Sun Microsystems Inc.)
Class-Path: /lib/utils.jar /lib/xmlutil.jar /lib/db.jar
Class-Path: /lib/log4j.jar /lib/referencedata.jar
Well, Java 1.5 rejects manifests with multiple class path entries!
So I decided to make my own, external manifest file, according to the specification. I continued the line with single spaces. This failed. After more attempts, I went back to the Web and discovered this post:
Oh, and another thing. For multiple lines, use two spaces not one...because the single space is removed when concatinated.