Contents of WAR , JAR and EAR files

whar are Contents of WAR , JAR and EAR files>
difference between these?
Asheesh_KumarAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bryan ButlerCommented:
These are all just zipp files created with the java jar tool or through an IDE that are used to run Java applications or "Enterprise Applications" (ie. java application server apps).

Jar (Java ARchive) files are basically what a java application uses and contain the class files which have the libraries/compiled code, properties files and any other resources for the app, such as classpath entry to specify other classes to load.  An app can be run by the command line.  
EX:  java -jar <jarfilename>.jar

War files (Web Applications aRchive) are "web apps" that are deployed on a server that implements JSP containers/servlets.  The have jsp, XML, html, and any other resources for the web server.  They are typically loaded/deployed through the "management console" of the java application server, such as webshpere, apache, etc.

Ear files (Enterprise ARchives) are JAR, WAR and EJBs combined.  They are also deployed through the server console.  

There are also RAR files (Resource Adapter aRchive) files whare are used in the JCA (J233 Connection Architecture).  These are Java archives which also store Classes, XML files, and other objects.  NOTE: this has no relation to the RAR compression format
0
Asheesh_KumarAuthor Commented:
can Jar file contains JSP or Servlet  or XML or Image file or all...?
can WAR file contains EJB component?

0
Bryan ButlerCommented:
They can contain them, but application servers (which are the things that JSPs/servlets run on) do not "deploy" jar files, only EAR and WAR.  So really they all can contain anything, but a JVM/command line will not handle or do anything with web components.  War files are the same way as far as they can contain anything, but you cannot "run a war file" from the command line, only deploy it on an app server.  Does this make sence?  
0
The Five Tenets of the Most Secure Backup

Data loss can hit a business in any number of ways. In reality, companies should expect to lose data at some point. The challenge is having a plan to recover from such an event.

Bryan ButlerCommented:
So basically....

JAR = java class file
WAR = JSP + JAR - (internet apps - webservers that run JSPs/Servlets)
EAR = J2EE/EJB/Eetc. + WAR - (enterpise apps - java application servers)

0
Bryan ButlerCommented:
And basically....

JARs run on JVMs, whereas WARs and EARs run on application servers.  Applications server use JVMs to run the various java programs in WAR/EAR/JAR files.  The application server also uses the other components of the WAR/EAR file for configuration and prosessing, such as interpreting the servlet/HTML code and other webserver/cgi tasks.
0
Asheesh_KumarAuthor Commented:
do you want to say we can put jsp or even ejb on JAR file.. but it won't work....
0
Bryan ButlerCommented:
That's what I'm saying.  It wont work, but you CAN do it.   Maybe on some servers if you referenced/"included" the JAR in a WAR that was deployed, then the ejb/jsp's may be available.  That doesn't seem right, but it would be a good security test.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Asheesh_KumarAuthor Commented:
excellent...
0
Bryan ButlerCommented:
Thanks for the points and the question.  Cheers.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.