Isn't a jar file just a zip file?

R

Ramon F Herrera

It is my understanding that a *.jar file is simply a *.zip file
with a different extension and some META-INF/MANIFEST.MF file
inside.

I tried to: unzip a jar file and zip it again (both in Windows
and Unix) and I got a correupted file message when I double clicked
on it.

What did I do wrong?

-Ramon
 
A

Andrew Thompson

It is my understanding that a *.jar file is simply a *.zip file
with a different extension and some META-INF/MANIFEST.MF file
inside.

A jar file does not even need a META-INF on occasions..
(You can load an applet or application directly out of a
..jar with no manifest, and I think WebStart can also
specify the main/applet class in the JNLP file.)
I tried to: unzip a jar file and zip it again (both in Windows
and Unix)

Using what? The jar tool that comes with the SDK?
(If so, what exact commands are you typing?)

There are tools that write zip files that are not compatible
with Java's understanding of a zip file format. One notable
one is WinZip when using maximum compression (though recently
I had reason to think that the core Java 1.5 had tightened it
even further, and even zips created with WinZip standard
compression were being rejected).
 
C

Chris Uppal

Ramon said:
It is my understanding that a *.jar file is simply a *.zip file
with a different extension and some META-INF/MANIFEST.MF file
inside.

The manifest sub-"file" is required to be physically first in the JAR, which is
a requirement that ZIP tools will probably not understand.

-- chris
 
K

Kevin McMurtrie

Ramon F Herrera said:
It is my understanding that a *.jar file is simply a *.zip file
with a different extension and some META-INF/MANIFEST.MF file
inside.

I tried to: unzip a jar file and zip it again (both in Windows
and Unix) and I got a correupted file message when I double clicked
on it.

What did I do wrong?

-Ramon

It probably is corrupted or there's a buggy utility involved. Jar files
really are ZIP files. The only difference is that JAR files have rules
for file organization.
 
R

Ramon F Herrera

After my experience, I decided to limit my use of the OS-provided zip
utilities only to expand files (never to compress them), and I create
them with 'jar'. I became convinced that I should not create jar files
with zip.
It probably is corrupted or there's a buggy utility involved.

Those so-called buggy utilities are:

- the "Send to Compressed (zipped) Folder" provided
by Microsoft in Windows XP.
- the "zip" utility that comes with RedHat Linux.

The above was tested in several different machines, with different
files.

-Ramon
 
R

Ramon F Herrera

I found out what I was was doing wrong (in Windows, anyway):

I had an extra folder inside another. Instead of selecting the top
level folder and right-click the "Send To Compressed (zipped) Folder" I
should select all of its contents.

Still not sure what the problem is on Linux, though.

Well, it's a moot point, it's safer to use 'jar'.

Thanks to all who answered.

-Ramon
 
A

Andrea Desole

Ramon said:
- the "zip" utility that comes with RedHat Linux.

I don't know what version you have, but the zip on my Mandrake is
working. I switched between zip and jar without problems. I didn't try
it on Windows
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,740
Latest member
AdolphBig6

Latest Threads

Top