wilx
wilx

Reputation: 18228

Order of the lines in Java manifest files

Does the order of lines in manifest file matter?

Somebody is trying to convince me that things break for him when the manifest file changes from

Manifest-Version: 1.0 
Class-Path: xxx.jar 
Main-Class: com.something

to

Manifest-Version: 1.0 
Main-Class: com.something
Class-Path: xxx.jar

(Main-Class and Class-Path lines are reversed.)

Upvotes: 6

Views: 1921

Answers (1)

aioobe
aioobe

Reputation: 420951

No, the order of those two lines should not matter.

Here's a quote from the documentation:

...

  • Versions:

    Manifest-Version and Signature-Version must be first, and in exactly that case (so that they can be recognized easily as magic strings). Other than that, the order of attributes within a main section is not significant.

  • Ordering:

    The order of individual manifest entries is not significant.

...

Internally the manifest is represented by a HashMap which is an unordered data structure. Here's the source code java.util.jar.Manifest if you wish to have a closer look.

Upvotes: 7

Related Questions