问题
I stumbled upon following problem - when I create .jar
file with more than 65k entries, java complains "Invalid or corrupt jarfile". Example:
$ # in fresh dir
$ for i in {1..70000}; do touch $i; done
$ jar cf app.jar {1..70000}
$ java -jar app.jar
Error: Invalid or corrupt jarfile app.jar
But if I use a bit less files, it works:
$ jar cf app.jar {1..60000}
$ java -jar app.jar
no main manifest attribute, in app.jar
I heard that there was 65k files limit in old .zip
file format, but Java 7 should use ZIP64 by default already. Why is this happening? Is there a way to fix it?
回答1:
Why is this happening?
It's a bug in Java 1.7.0 (aka Java 7)
- http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7191282.
Fixed in Java 1.7.0 p40 or later, apparently.
Is there a way to fix it?
According to the bug report, the workaround (for Java 1.7.0) is to launch the application without using the -jar
option.
FWIW, there is also a bug in javac
s handling of ZIP64 format JAR files:
- http://openjdk.5641.n7.nabble.com/javac-doesn-t-work-with-jar-files-with-64k-entries-tp103719p103816.html
- http://openjdk.5641.n7.nabble.com/8003512-javac-doesn-t-work-with-jar-files-with-64k-entries-tp109359.html
来源:https://stackoverflow.com/questions/18441076/why-java-complains-about-jar-files-with-lots-of-entries