Contents of WAR , JAR and EAR files

whar are Contents of WAR , JAR and EAR files>
difference between these?
Asheesh_KumarAsked:
Who is Participating?
 
Bryan ButlerConnect With a Mentor Commented:
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
 
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
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
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
 
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
 
Asheesh_KumarAuthor Commented:
excellent...
0
 
Bryan ButlerCommented:
Thanks for the points and the question.  Cheers.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.