I've run into interesting problem which is absolutely new to me. As I've suddenly discovered, Jar specification says that, being included, META-INF
and MANIFEST.MF
must be first and second entries of *.jar
package and not just directory and file within archive.
I'm working with Java framework being very watchful about this requirement and not as much verbose. How do I check that META-INF
and MANIFEST.MF
are properly ordered within jar?
UPDATE: Many of jars are third-party, and there are many of them. I'm not able to open these jars in notepad, excel, hexeditor, photoshop or whatever looking for byte sequences. I need command-line tool. Thanks!
UPDATE 2: Here is the reason why I'm asking this question: http://www.mail-archive.com/dev@felix.apache.org/msg17097.html
The jar tool with the JDK automatically adds them first, so there shouldn't be anything you have to do. If you really want to check, get a hex editor and look for the strings 'META-INF' and 'MANIFEST.MF' before any other file names.
The following command will list the contents of a JAR in order:
Note that there is no actual requirement in the JAR specification for
META-INF/MANIFEST.MF
to appear first. However JARs built by thejar
tool (supplied with the JDK) do have the manifest first, and therefore it has become a convention.To fix the broken JARs:
SEE: MANIFEST.MF must be the first resource in a jar file – here’s how to fix broken jars