1833541 Members
2913 Online
110061 Solutions
New Discussion

Re: Java ZIP failure

 
Jim Davee
New Member

Java ZIP failure

I've written several apps in Java 1.4x that run on both Win2k and HP-UX 11i without any code change (as expected with Java).

But now I've got a problem that I can't fix. I have a ZIP file that was created by one of my Java apps, but it can't read it.

The same exact file is readable on Windows by the same Java app, WinZIP, etc. and PKUnzip for HP-UX can read the file just fine as well.

But when I try to open it on HP with the Java app I get:

Unhandled exception: java.util.zip.ZipException: error in opening zip file at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.(ZipFile.java:124)
at java.util.zip.ZipFile.(ZipFile.java:72)
at Unzip.unzip(Unzip.java:38)

The line itself that generates the failure is:
ZipFile zipFile = new ZipFile(file_in);

I can find nothing that describes how to resolve this problem, or even that others have had it happen. I've tried Java 1.1, 1.2, 1.3, 1.4.1, and 1.4.2 and all fail on HP-UX 11 and 11i.

I also created a new ZIP file using PKZip for Unix, but the Java app couldn't open it either.

What could be the problem?

Thanks,
Jim
3 REPLIES 3
Stephen Keane
Honored Contributor

Re: Java ZIP failure

Can you not trap the exception and print out the exception detail (if it is available - ZipException can be created with a null argument). That might give you a clue as to the problem.

Can java.util.jar.JarFile open it?
Jim Davee
New Member

Re: Java ZIP failure

Stephen,

That is the trapped error, believe it or not! This "error in opening zip file" references something with the file format, but that doesn't explain why the file on Unix works with other ZIP apps, and the app in Java works on other platforms.

I did see something about HP-UX patches with ZIP files, but that was from 2002 or so and I know the admins keep this system patched up.

I'll try the other method to see what happens.

Thanks,
Jim
B. Hulst
Trusted Contributor

Re: Java ZIP failure

Hi,

There is an excellent article on using pkzip and gzip in java.

Check this link:

http://java.sun.com/developer/technicalArticles/Programming/compression/

Regards,
Bob