Monday, 26 August 2013

Why java complains about jar files with lots of entries?

Why java complains about jar files with lots of entries?

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?

No comments:

Post a Comment