Junky's IT Notebook

统计

留言簿(8)

积分与排名

WebSphere Studio

阅读排行榜

评论排行榜

Jar War Ear

Jar War Ear

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:


JAR files = collection of class files
WAR files = collection of class, JSP, XML files
EAR files = collection of JAR, WAR, and EJBs
 


JAR (Java ARchives)


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.

 

WAR (Web ARchives)


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.
 

EAR (Enterprise ARchive)


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.

posted on 2006-05-21 14:08 junky 阅读(386) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: