Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Order of the lines in Java manifest files

Tags:

java

manifest

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.)

like image 321
wilx Avatar asked Aug 22 '11 10:08

wilx


1 Answers

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.

  • http://www.massapi.com/source/jdk1.6.0_17/src/java/util/jar/Manifest.java.html
like image 79
aioobe Avatar answered Sep 23 '22 14:09

aioobe