Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've heard that they are the same, but I would like to know if the compression is always the same. Can I always rename .zip files to .war, and vice-versa?

share|improve this question
This or this? – BlueRaja - Danny Pflughoeft Apr 22 '11 at 16:16
up vote 8 down vote accepted

If you mean this, then, according to the wiki page, the .war format is the same as the .jar format. .jar files are just .zip files which contain compiled java code, meant to be used as a library or executable. So the answer would be no, there is no technical difference; but .jar files should only be used for what they're intended for, not as general-purpose archives.

If you mean this, then there is a slight difference: this .war format is a gzipped-tar (.tar.gz) file, again meant to hold specific data (web pages). Gzip and Zip both use the same compression algorithm; however:

Gzip is not to be confused with the ZIP archive format, which also uses [the DEFLATE compression algorithm]. The ZIP format can hold collections of files without an external archiver, but is less compact than compressed tarballs holding the same data, because it compresses files individually and cannot take advantage of redundancy between files.

In both cases, you should only use the .war extension for the specific purpose it's intended for.

share|improve this answer

ZIP files can contain any kind of file and folder structure.

WAR files (Java Web Application Archives) are based on ZIP, but have a defined folder structure and requirements to some of the files in there (e.g., some stuff needs to be in a WEB-INF directory).

So yes, you can rename a .war file to .zip to view its contents or unzip it using a tool that doesn't know about this relationship between the file format. But not just any .zip file will make a working web application — you'll have to be careful in creating the file and folder structure you're bundling up.

share|improve this answer
@Randolf Please refrain from editing any of my posts in the future. Thank you. – Daniel Beck Apr 22 '11 at 18:49
@Daniel Beck: Sorry, did I do something wrong? – Randolf Richardson Apr 22 '11 at 18:51
@Randolf It's a discouraged edit as per the /reputation explanation for the edit privilege (changing a single character) and really a matter of personal style whether to use or not use the comma after e.g. (at least from what I've gathered). I'd actually welcome edits that substantially and objectively improve my posts, but have never even had a single one of those, so I'm kind of wary of them. Plus I'm kind of proud of the low number of edits even though I'm not a native speaker ;) – Daniel Beck Apr 22 '11 at 18:58
@Randolf I don't think you can somehow see them listed (as they're in the Responses tab), so FYI: 1, 2, 3, 4, 5, and this one. – Daniel Beck Apr 22 '11 at 19:01
@Daniel Beck: Normally my edits are fixing major things. This was one exception where I corrected a minor error. I had no idea it was causing problems with reputation, and my intentions are to maintain the high quality of content. I'll try to remember not to edit your posts, but I also don't want to find myself in a "walking on eggshells" situation having to remember who's posts not to edit, so please forgive me in advance if I do forget (this web site doesn't seem to provide any system for add custom notes next to users, otherwise I could add such a note). – Randolf Richardson Apr 22 '11 at 19:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .