my dog learned polymorphism*
The moose likes Java in General and the fly likes What are ear,war and jar files ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "What are ear,war and jar files ?" Watch "What are ear,war and jar files ?" New topic
Author

What are ear,war and jar files ?

jose chiramal
Ranch Hand

Joined: Feb 12, 2010
Posts: 266
EAR is enterprise archive file

WAR is webarchive file

JAR is javaarchive file. I would like to know the difference between WAR and JAR. Can i say WAR is nothing but JAR in zip format ?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14117
    
  16

jose chiramal wrote:Can i say WAR is nothing but JAR in zip format ?

No, that's not where the difference is. EAR, WAR and JAR files are all essentially just JAR files, but in EAR and WAR files there are some special configuration files stored inside the EAR or WAR, which a Java EE application server or servlet container uses to deploy the application inside the EAR or WAR.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19685
    
  20

jose chiramal wrote:Can i say WAR is nothing but JAR in zip format ?

Jesper is right. In fact, JAR is just the same. All are just ZIP files with special files and folders inside. For JAR that is the META-INF folder and the META-INF/MANIFEST.MF file. WAR files have these as well, and add the WEB-INF folder and WEB-INF/web.xml file. No idea about EAR but like WAR it's a JAR file with extra files and folders.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10069
    
163

In addition to what Rob mentioned, EAR files assemble the WAR, JAR and other similar component artifacts together. So typically inside and .ear file, you will see a .war and .jar files. A .ear file can also have a META-INF/application.xml.


[My Blog] [JavaRanch Journal]
jose chiramal
Ranch Hand

Joined: Feb 12, 2010
Posts: 266
What does META-INF have can i say the version number or sthg??


Application.xml has the context root etc right ?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14117
    
  16

Files such as WEB-INF/web.xml and META-INF/application.xml are deployment descriptors - files that contain the configuration of web applications and enterprise applications. If you want to know exactly what those files look like, then look at the schemas and DTDs for them.

Also see the Java EE 6 Tutorial.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: What are ear,war and jar files ?