Search This Blog

Thursday 21 January 2021

Understanding of Java Archives JAR, WAR, EJB and EAR

 JAR

A JAR (Java Archive) is a package file format typically used to aggregate many Java class files and associated metadata and resources (text, images, etc.) into one file for distribution.

JAR files are archive files that include a Java-specific manifest file. They are built on the ZIP format and typically have a .jar file extension.

Common JAR file operations
OperationCommand
To create a JAR filejar cf jar-file input-file(s)
To view the contents of a JAR filejar tf jar-file
To extract the contents of a JAR filejar xf jar-file
To extract specific files from a JAR filejar xf jar-file archived-file(s)
To run an application packaged as a JAR file (requires the Main-class manifest header)java -jar app.jar
To invoke an applet packaged as a JAR file
<applet code=AppletClassName.class
        archive="JarFileName.jar"
        width=width height=height>
</applet>


WAR or Web Application Archive

 A Web Application is a group of server-side resources that create an interactive online application. 

Server-side resources include:
  • Servlets ( small server-side applications )
  • JSPs (dynamic content)
  • Static documents (HTML, images)
  • Server-side classes
  • Client-side applets and beans
Before deploying an application package and registering it with a WLS server.

Follow these steps to package a Web App
  1. Arrange resources in a prescribed directory structure
  2. Develop web.xml Deployment Descriptor (or copy as required)
  3. Develop weblogic.xml Deployment Descriptor (WLS-Specific)
  4. Archive Web App into .war file using jar command
  5. Deploy Web App onto Weblogic Application Server
  6. Configure Web App with WLS Administration Console
The structure of Web Application is defined by the Servlet Specification.


Web Applications are configured through deployment descriptors web.xml and weblogic.xml
  • Define run-time environment
  • Map URLs to Servlets and JSPs
  • Define application defaults such as welcome and error pages
  • Specify J2EE security constraints 
  • Define work managers for applications
  • Set the context-root for the application
web.xml file : The web.xml file is a deployment descriptor for configuring 
  • Servlets and JSP registration 
  • Servlet initialization parameters
  • JSP tag libraries
  • MIME type mappings
  • Welcome file list
  • Error pages
  • Security constraints and roles
  • Resources
  • EJB references
weblogic.xml file: The weblogic.xml file is a Weblogic server specific deployment descriptor for configuring 
  • JSP Properties
  • JNDI mappings
  • Security role mappings
  • HTTP session parameters
  • Work Managers
  • Context root
  • Virtual Directory mappings
  • Logging parameters
  • Library modules



























EJB

Enterprise JavaBeans Standardizes development and deployment of Java server components.

The EJB specification defines relationships between:
  • The EJB and its container
  • The container and the application server
  • The container and the client
Types of EJBs


























EJB Application Directory Structure:

















EAR

An Enterprise Application is a grouping of several resources into one deployable unit packaged in an .ear file.

These resources include:
  • Web Applications (.war)
  • EJB Applications (.jar)
  • Java Applications (.jar)
  • Resource Adapters (.rar)
Enterprise Application Directory Structure 















































Uses of Enterprise Applications :
  • To avoid Name space clashes
  • Declare Application-wide security roles
  • Deploy an Application as one unit
  • Share Application wide EJB resources
  • Configure local JDBC data sources
  • Configure local JMS resources
  • Configure local XML resources
weblogic-application.xml file: This is a deployment descriptor for EAR file use to configure Weblogic Specific features: 
  • XML parses
  • XML entity mappings
  • JDBC data sources
  • JMS connection factories and destinations
  • Security realms


No comments: