Hi !
This is my understanding,
A jar file is a java archive file, which bundles java classes(utility) with some static files like images or videos for easy accessibility.
A war file is a web application archive which bundles JSP/Servlet classes, html, images and videos.
My question is, can jar have only java classes and not JSP files or html files. But war file can also have jsp files and html files, is that the prime difference between jar and war files.
Thanks
AJP
-
About jar and war file (3 messages)
- Posted by: A JP
- Posted on: December 21 2001 15:32 EST
Threaded Messages (3)
- About jar and war file by Mark Hills on December 21 2001 17:50 EST
- About jar and war file by Jim Hall on December 24 2001 10:38 EST
- About jar and war file by Mark Hills on December 31 2001 11:12 EST
- About jar and war file by Jim Hall on December 24 2001 10:38 EST
-
About jar and war file[ Go to top ]
- Posted by: Mark Hills
- Posted on: December 21 2001 17:50 EST
- in response to A JP
AJP:
The main difference between a JAR and a WAR is that a JAR is not really a single purpose format, while a WAR is. With a JAR file, you can package lots of different things. Usually you package up Java classes, but you could put pretty much anything into a JAR file, and you can create JARs that have whatever files and directory formats you want. For instance, Oracle (at least in 8.1.x) actually uses JAR files to distribute the Oracle software on the install CDs, and IBM uses them to distribute an installable version of the documentation for WebSphere. Technically you can put JSP pages, HTML pages, servlet classes, etc. in a JAR, but you generally don't -- you use a WAR.
WAR files are JAR files with a specific format. This format is defined in the servlet spec (which you can look at on the java.sun.com site). Essentially, the WAR file is a standard format for web applications that has specific directories and specific files. This includes a WEB-INF directory, a WEB-INF/web.xml file used to describe the application, a WEB-INF/lib directory for JAR files used by the application, and a WEB-INF/classes directory for class files that aren't distributed in a JAR. You would put the pages (JSPs and HTML) in the WAR as well. Then, you can distribute your application as one file, instead of as a collection of images, HTML pages, and Java classes.
Hope this helps!
Mark -
About jar and war file[ Go to top ]
- Posted by: Jim Hall
- Posted on: December 24 2001 10:38 EST
- in response to Mark Hills
Is there any benefit, other than having everything in a single file, to using war/jar files for application deployment? -
About jar and war file[ Go to top ]
- Posted by: Mark Hills
- Posted on: December 31 2001 11:12 EST
- in response to Jim Hall
The major benefit is having everything in a single file. It's just easier to distribute a jar or war file than it is to distribute an entire directory tree. This is especially true with web applications, since you have classes, html pages, xml files, etc. to worry about, not just Java classes.
With some application servers, you have to use jar or war files, so you wouldn't have a choice. EJBs are generally distributed in a jar file, and tag libraries often are as well. Even when it's not a requirement, it's often very convenient. App servers like WebSphere, Weblogic, JRun, etc can take a war file and directly deploy it without requiring much beyond the name of the war file to deploy.
Mark