[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1726
  • Last Modified:

Contents of WAR , JAR and EAR files

whar are Contents of WAR , JAR and EAR files>
difference between these?
0
Asheesh_Kumar
Asked:
Asheesh_Kumar
  • 6
  • 3
1 Solution
 
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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now