看了新公司的发布目录,感叹公司把Java相关的发布包用得出神入化,从最简单的Jar到最常见的War,以及中大型J2EE工程中的Ear,然后是JBoss特定的Sar,以及被Jboss收购后的Hibernate提供的Har,真的是被AR搞混头了,特此列举一下:

  • JAR:java类文件的打包发布
  • WAR:WEB应用的打包发布
  • EAR:J2EE应用的打包发布,一般包括EJB
  • SAR:JBoss的Service打包发布
  • HAR:Hibernate打包发布

2007年7月13日更新:
一个E文的,好像比我的全面:

Intro to JARs, WARs, SARs, RARs and EARs

Anyone worth calling oneself a java developer would know what a JAR file is. It’s an archive, just like ZIPs and TARs are. In addition to being a simple archive, a JAR file can store some very useful meta information about its contents. A special file, META-INF/MANIFEST.MF is where a jar records meta information.

EJBs are packaged as jar files as well, albeit with one or more special files under META-INF, called deployment descriptors.

A WAR file packages a web application. What does a web application consist of? It consists of

  1. HTML/JSP pages and other resources such as images/javascript files/stylesheets that need to be reachable via URLs.
  2. Additional files such as java servlets, utility classes and jars for use in servlets/JSPs and deployment descriptors that should not be reachable via URLs.

The latter are stored under a special folder named WEB-INF. Both are then archived in JAR whose extension is modified as WAR to distinguish it as a java web application.

Similarly, RAR files are JAR files used to package resource adapter modules as defined under the J2EE Connector Architecture (JCA) and SAR files are the ones used to package JMX-enabled services in JBoss.

Just as all rivers are destined to go merge with the sea, all these archives that relate to a single enterprise application may be packaged under one EAR.