Saturday, May 14, 2011

Difference between JAR, WAR and EAR


jar - Java archive (file with .jar extension) [For simple java application]
war - Web archive (file with .war extension) [For simple java + jsp/servlet]
ear - Enterprise archive (file with .ear extension) [For simple java + jsp/servlet + EJB]
All three files are zipped file system and used for different purpose.

Understanding them one by one
JAR : JAR is a platform-independent file format that aggregates many files into one. Typically a JAR file contains the class files and auxiliary resources like libraries files, properties file, image, sound etc.
WAR : It is used to deployed in web application like Tomcat. It typically contains servlets, JSPs and their supporting classes and files. A servlet container like Tomcat is required to deploy these file. There are special files and directories within a WAR file. A WAR has a specific directory structure. The top-level directory of a WAR is the document root (WEB-INF) of the application. The document root is where JSP pages, client-side classes and archives, and static Web resources are stored. WEB-INF contains web.xml, classes, lib and Tag library descriptor files.
EAR : An EAR file is a standard JAR file with a .ear extension which is a generally J2EE application. It contains one or more entries representing the modules of the application, and a metadata directory called META-INF which contains one or more deployment descriptors. It is a top-level container which contains modules like: EJB modules, web modules, application client modules etc and deployed to an application server like WebLogic, WebSphere, JBOSS, etc. It might contain WARs, JARs, etc.
EAR = WAR(Web module) + JAR(can be EJB module or application client module)

No comments:

Post a Comment