• Post Reply Bookmark Topic Watch Topic
  • New Topic

Jar vs Zip ?  RSS feed

 
David Blaine
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can we also distribute our eclipse java project as a zip file instead of a jar ? If yes, then what are the advantages/disadvantages of doing so ?
I looked at this link, but it did not answer my question.

http://stackoverflow.com/questions/5871053/java-war-vs-jar-what-is-the-difference


 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you can distribute your application as a zip file. The benefits of using aJAR can be found at the top of this page. I can't think ofa benefit of using a zip.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Blaine wrote:Can we also distribute our eclipse java project as a zip file instead of a jar ? If yes, then what are the advantages/disadvantages of doing so ?

The two things perform different functions: jar is an archiving tool, based on an old Unix utility called tar (short for "tape archive", which gives you some idea how old it is). Zip is a compression utility, which just happens to have archiving features.

You can also compress jars, and it's distinctly possible that it uses zip (or gzip) behind the scenes to do it, so there really isn't much point in zipping things yourself because you're just duplicating effort.

Winston
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A .jar file *is* a .zip file (so it can be handled using any zip tool), except that it also has the added benefits that come with whatever information is part of the manifest file.
 
Ivan Jozsef Balazs
Rancher
Posts: 999
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Winston Gutkowski wrote:
The two things perform different functions: jar is an archiving tool, based on an old Unix utility called tar (short for "tape archive", which gives you some idea how old it is). Zip is a compression utility, which just happens to have archiving features.


Well, the parameterizing of "jar " comes from "tar", but it is -as pointed out earlier- based on "zip".
As said above:
  • a jar file is a zip file (and no tar file)
  • any zip utility can handle a jar archive


  • oracle@izsak:/tmp> tar tvf ds.jar
    tar: This does not look like a tar archive
    tar: Skipping to next header
    tar: Error exit delayed from previous errors
    oracle@izsak:/tmp> unzip -l ds.jar
    Archive: ds.jar
    Length Date Time Name
    -------- ---- ---- ----
    0 06-06-13 15:49 META-INF/
    87 06-06-13 15:49 META-INF/MANIFEST.MF
    1447 06-06-13 15:49 ds.java
    1753 06-06-13 15:49 ds.class
    -------- -------
    3287 4 files
     
    Winston Gutkowski
    Bartender
    Posts: 10575
    66
    Eclipse IDE Hibernate Ubuntu
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Ulf Dittmer wrote:A .jar file *is* a .zip file (so it can be handled using any zip tool), except that it also has the added benefits that come with whatever information is part of the manifest file.

    It is? I thought it was a tarfile (or possibly a tgz). Indeed, I seem to remember using tar -tvf to look at it on Unix, and it seems unlikely that an old command like that would have been retrofitted just to handle jars - Mind you, that was quite a while ago now.

    What I suspect is that most ZIP utilities can read tarfiles these days.

    Winston
     
    Steve Luke
    Bartender
    Posts: 4181
    22
    IntelliJ IDE Java Python
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Winston, see this page:

    http://docs.oracle.com/javase/7/docs/technotes/guides/jar/jar.html

    The JAR file spec pretty much days it is a ZIP file.
     
    Winston Gutkowski
    Bartender
    Posts: 10575
    66
    Eclipse IDE Hibernate Ubuntu
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Steve Luke wrote:Winston, see this page:
    http://docs.oracle.com/javase/7/docs/technotes/guides/jar/jar.html
    The JAR file spec pretty much days it is a ZIP file.

    In which case: my apologies Ulf, I stand corrected.

    Winston
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!