my dog learned polymorphism*
The moose likes Servlets and the fly likes War with WAR, EAR and JAR Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "War with WAR, EAR and JAR" Watch "War with WAR, EAR and JAR" New topic
Author

War with WAR, EAR and JAR

Sachin Ramesh Vir
Greenhorn

Joined: Sep 15, 2005
Posts: 23
Hi,
What are the uses of having JAR, WAR and EAR (some other is there??)
I know about JAR file. As far my knowledge the JAR file is used when we want to give our application to the cilent, by placing all the class files with one manifest file stating which one has the main method.

Correct me if I am wrong. Please tell about WAR and EAR? Why there are using? Where it is frequently used? How to WAR or EAR? How to retireve the files from WAR and EAR(I don't know whether it has files like JAR)
Vasudhaiv Naresh
Ranch Hand

Joined: May 13, 2005
Posts: 57
Hi Sachin,
JAR - Java Archive - for standalone applications
WAR - Web Archive - for web applications
EAR - Enterprise Archive - for enterprise applications
(WAR/EAR files need containers)
Hope this is clear.
Regards,
Naresh
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2057
winzip can expand them jar/ear/war

you create a war the same way you create a jar....exactly the same way....actually you can make it a jar, then rename to war

within the ear, you can find wars and jars....

make love not war....
Madhav Penubala
Greenhorn

Joined: Sep 26, 2005
Posts: 6
Hi Sachin,

Am trying to explain in detail...., 'war' files contains jsp, servlets, html etc., not the ejb files. This 'war' can run in any web server like Tomcat. But 'ear' files contains 'war' files as well ejb files. This will run in any Application server like JBoss,Weblogic. And 'jar' files is basically used for only standalone applications.


Creating war & ear files
------------------------

(1) sample folder may contains java,jsp,servlets,html,jpeg etc., is converted into war file by this command.

C:\Tomcat4.1\webapps\sample>jar -cvf sample.war *



(2) sample folder may contains sample.war and ejbs with may also contains html,jpeg etc., is converted into ear file by this

command.

C:\Tomcat4.1\webapps\sample>jar -cvf sample.ear *



unzipping and extracting war & ear files
----------------------------------------

(1) C:\Tomcat4.1\webapps\sample1>jar -xvf sample.war.

it will unzip and extracts all its content files from sample.war file


(2) C:\Tomcat4.1\webapps\sample1>jar -xvf sample.ear.

it will unzip and extracts all its content files from sample.ear file



Creating the jar files
----------------------

Creating a deployment file after you finish developing your enterprise bean, you need to package all the class files into
one .jar file. For suppose, the ejb directory contains three files: Adder.class, AdderHome.class, and AdderBean.class. The

'METAINF' directory contains one file: the ejb-jar.xml file, the deployment descriptor.

Follow these steps to create the deployment file:

1. Change directory to the parent directory of both com and META-INF.
2. Assuming jar.exe is already in the path, type the following:


jar cfv adder.jar com/brainysoftware/ejb/* META-INF/ejb-jar.xml


3. This creates a jar file called adder.jar.
Sachin Ramesh Vir
Greenhorn

Joined: Sep 15, 2005
Posts: 23
Hi Madhav Penubala ,

Thank you very much for your reply. It's very clear explanation. Thanks a lot!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: War with WAR, EAR and JAR