Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

why use .war file

  Asked By: Maddison    Date: Jul 19    Category: Java    Views: 2312

Why do we need to use .WAR file when we could use the .JAR file
itself. All the .WAR, .JAR, .EAR is confusing me.... What is the need
for all these file extensions when just .JAR could serve the same



4 Answers Found

Answer #1    Answered By: Ginger Snyder     Answered On: Jul 19

War files specified Web Application Archive and jar
files contain java class files as a library and EAR
files specified Enterprise Archive.
Ear files contain any application file  for j2ee
framework such as war  file, jar  files, ejb class files
and other j2ee files, otherwise war files include only
web files such as images(gif, jpg, ...)
, html, jsp, xml, css , java class files.
A ear file may contains some war files.This extensions
are standards of j2ee for deploying and packaging
applications. All of standard j2ee application
servers(such as Bea Weblogic or IBM WebSphere)
recognize j2ee web applications with war files and
enterprise applications with ear files and manage your
j2ee application with these extensions.

Answer #2    Answered By: Jimmy Abp     Answered On: Jul 19

- For adding some specialization and recognition of content for
different archived files just like file  extentions *.jpg *.bat *.sh *.html
even though *.bat is essentially a text file ...

- Put some limitations/features for specific uses e.g. we expect .war to
be a web archive so it would have WEB-INF subdirectory. Also we don't
expect to have EJB Container stuff in .war. These give hints to deployer
(server)application on what Deployment Descriptor to look for.

there are some other delicacies as well.

Answer #3    Answered By: Rickey Scott     Answered On: Jul 19

I think the structures of all these archives are the same, and different extensions just used as an identifier.
Maybe I should go to read some of the sun's docs now.

Answer #4    Answered By: Monique Perry     Answered On: Jul 19

There's no need to have the ".war" extension for Web
Applications. Indeed, you can use the same ".jar"
extension and most of the containers are ok with that.

One encouraging reason to have .war extensions for Web
Applications and .ear for Enterprise ones, is that you
don't have to guess if the archive you have is a
simple java library like ant, or a web application, or

Didn't find what you were looking for? Find more on why use .war file Or get search suggestion and latest updates.