JAR, WAR, EAR

 

 

JAR

WAR

EAR

英文Java Archive file  Web Archive file Enterprise Archive file
包含内容class、properties文件,是文件封装的最小单元;Servlet、JSP页面、JSP标记库、JAR库文件、HTML/XML文档和其他公用资源文件,如图片、音频文件等;除了包含JAR、WAR以外,还包括EJB组件
部署文件application-client.xml web.xml   application.xml
级别

 

如果想生成war文件:可以使用如下命令:jar -cvf web1.war *
如果想查看web1.war中都有哪些文件,可以使用命令:jar -tf web1.war
如果想直接解压web1.war文件,可以使用命令:jar -xvf web1.war
另外,也可使用winrar软件选择zip压缩方式,并将压缩文件后缀名改为war即可压缩生成war文件;同样使用winrar软件可以强行打开war 文件,或者强行解压war文件
使用jar命令与winrar软件的区别在于前者在压缩文件的同时会生成MetaINF文件夹,内包含MANIFEST.MF文件。

 

转自: http://apps.hi.baidu.com/share/detail/30355098

================================ 

 

Every one knows, what you mean when you talk about a zip file. It is an archive for the stuff you want to compress and save or give to someone else. And, the fancy ones, allow you to maintain the directory structure of you multiple directories of files, when it gets to the other end.

Along the lines of evolution, the java community discovered that it would be easier to deploy their beloved lines of code, if they could pack it into a single compressed file format.

Their evolution created these terms that you have heard of:

<!--mstheme-->
JAR files = collection of class files
WAR files = collection of class, JSP, XML files
EAR files = collection of JAR, WAR, and EJBs
 <!--mstheme-->

<!--mstheme-->
JAR (Java ARchives) <!--mstheme-->


It is really straight forward.
The JAR file is a Java Archive. The WAR file is a Web Archive. And finally, in the 21st century, the EAR file is, what else, and Enterprise Archive.

Very plain, and un-esoteric, when you really think about it. But, it is strange the first time through.

This world actually uses the terms archive and library interchangeably. All of the formats, are your program zipped with a directory structure. So, that if you give it to your friend or your friendly server, they both know where things belong, and your program will still run as it did on your computer.

The most basic archive is the JAR file. Normally is it is simply a compressed set of your java class files. When you run your java application, it knows were to find its parts, by referencing the structure. The normal.com.cezwright.myapp.starthere and the such. So, a JAR is either a complete application or it is just a set of utilities that you can call from your application.

The JAR file, is a bit more evolved that a plain archive or library, because it also can contain meta-data about the configuration of your application or even include a library that you want to or need to distribute with it.

The good news, is that you can call or access the classes in the JAR without needing to decompress them to the harddrive. They will run as is, by the magic of the java engine!


So, for simple classes you can use this format, which was the beginning of it all.

 

<!--mstheme-->WAR (Web ARchives) <!--mstheme-->


Then, inorder to keep people from seeing your code, by viewing the source in your browser, someone invented JSPs. You write the JavaScript, but it is only visible on the server and not on the HTML page( that is why JSP was born).

This meant that you now hard more complicated information, that needed to be placed inside of the JAR. So, this gave birth to the next format on the evolutionary scale. The WAR file.


Now we have a structure that support JavaServer Pages and servlets. And, by the way, those things need to have HTML and some XML in them too. Oh, a web application archive structure.

Here we can upgrade the structure of the WAR file, and maintain a more complex conglomeration of things. And, the configuration information that a java server (container) would need to run it.

Then someone said, "Here lets keep the deployment stuff in there, and the application can self-deploy!"

technology came along, the need arose to package additional application objects such as JSPs, servlets, and HTML and XML files. Also, Java Web applications require more complex configuration information.

These new objects and complex configuration made the WAR file, the standard way to go. And things like Tomcat and Websphere were taught how to read and deploy them. No more long nights putting things together and placing them on the server, and pushing the (or clicking) the buttons.

Unlike the JAR file application, the server can not simply run the compressed file. And, the server deploys your application. So, when the server detects that either a new or updated war file has been saved to its special place, it will extract (expand) your entire application from the WAR archive to the server's web applications directory. And the directory structure, will look just like it did on your computer when you first created it. And now we are ready to run. The magic of auto deploy.

So now your entire web application is in one file. The WAR. The war is won.
 

<!--mstheme-->EAR (Enterprise ARchive) <!--mstheme-->


Until, enter the enterprise!

These comparatively giant applications with a development environment called Java 2 Enterprise Edition. So, the EAR was born!

Now we can have Enterprise Java Beans, in the archive as well. Plus, we can still include multiple WAR and JAR files in this one single file.

No wonder, the java community loves ANT.

 

转自: http://www.blogjava.net/junky/archive/2006/05/21/47284.aspx

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值