Thursday, June 11, 2009

what is the difference between JAR, WAR and EAR files

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.

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)


  1. Hi Binod,

    Everything is fine. But my suggestion is why dont you try to create videos with explanations of all your stuff. I think that will be very useful and helpful and easy to understand also.

    and I am very much impressed with your work and want to follow all your posts.
    you can mail me


  2. hi
    i thank u for the explanation u posted the above.
    N i should go with ravi the one who commented u. So if u had a chance plz go do video for explanation.

    thank u

    my mail id
    i'm weak in java. so if possible send ur works to my id.

  3. Hi...i want to save an image object generated in an applet onto my laptop, as in, in a location i specify. Generally, only a BufferedImage object can be saved. Is there any way to save the Image object directly??


Please put your feedback or your any question related to this blog. Thanks.