Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Zip file produced by Java can't be opened in OS/390 (Mainframe)

823116Dec 11 2010 — edited Dec 13 2010
A Java program creates a zip file which has to be opened by Pkunzip on mainframe.

The problem is this, mainframe can't open the zip file. But when we open the file in WinRar and rename the one file in it, rename it back to the original name (re-zip the file) it can be opened by Pkunzip.

Here's the zip format spec. : http://www.pkware.com/documents/casestudies/APPNOTE.TXT

according to the spec I tried to find the differences of both files (untouched zip file created by Java and re-zipped file).

the result is as in the picture attached.

I used a file "a.txt" which content is simply "1234567890".

the crc of a.txt is :
DEC : 639479525
HEX : 261DAEE5

the zip file created by my Java program includes 4 sections (I've marked those with a green underscore) :
0x04034b50 <- A. Local file header:
0x02014b50 <- F. Central directory structure:
0x08074b50 <- C. Data descriptor:
0x06054b50 <- I. End of central directory record:

a zip file created by right-clicking a.txt and choosing "add to archive..." has fewer sections.
But that's not important right now, since I know that PKUNZIP on the mainframe does accept archives created by Java and rezipped by WinRar.


The zip files created by java doesn't include
1 - the crc
2 - the compressed file size
3 - the uncompressed file size

in the "local file header". Those 3 are present and set in other parts of the file, though, e.g. in the "central file header signature" section.

And the 'Version made by' flag changes from "14 00" to "17 0b", but I don't think that's the problem PKUNZIP is complaining about.


I've also tried to set the crc and the size explicitly, but the result is the same as described above :
view plaincopy to clipboardprint?
ZipEntry entry = new ZipEntry(fileToBeZipped);
entry.setSize(inputFile.length()); // <-- doesn't affect the "local file header" section
CRC32 crc32 = new CRC32();
...
while ((len = is.read(bytes)) >= 0) crc32.update(bytes, 0, len);
System.out.println("Value of crc after setCRC method : " + entry.getCrc()); // <-- prints 639479525
entry.setCrc(crc32.getValue()); // <-- doesn't affect the "local file header" section

The files' view in a hex editor :
created by Java program http://www.coderanch.com/forums/posts/downloadAttach/1732
re-zipped by WinRar http://www.coderanch.com/forums/posts/downloadAttach/1731

I'm stuck at this point. Does anybody have a clue how to solve this ?

Edited by: user9933068 on Dec 11, 2010 2:13 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 10 2011
Added on Dec 11 2010
4 comments
803 views