问题
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.)
回答1:
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
来源:https://stackoverflow.com/questions/7145790/order-of-the-lines-in-java-manifest-files