Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- JAR
- A JAR (Java ARchive) file, is an archive file format typically used to aggregate many Java class files and associated metadata and resources (text, images and so on) into one file to distribute application software or libraries on the Java platform.
- JAR.jar
- |-- META-INF/
- | |-- MANIFEST.MF
- | `-- INDEX.LIST
- |-- classFile01.class
- |-- classFile02.class
- |-- classFile03.class
- `-- resources/
- `-- images/
- |-- imgFile01.tiff
- `-- imgFile02.tiff
- WAR
- A WAR (Web application ARchive) file is a JAR file used to distribute a collection of JavaServer Pages, Java Servlets, Java classes, XML files, tag libraries and static Web pages (HTML and related files) that together constitute a Web application.
- WAR.war
- |-- index.html
- |-- resources/
- | |-- file01.css
- | |-- file02.css
- | |-- file.js
- | `-- images/
- | |-- image01.jpg
- | |-- image02.gif
- | `-- image03.png
- |-- jspFiles/
- | |-- jspFile01.jsp
- | |-- jspFile02.jsp
- | `-- jspFile03.jsp
- `-- WEB-INF/
- |-- lib/
- | |-- library01.jar
- | |-- library02.jar
- | `-- library03.jar
- |-- classes/
- | |-- classFile01.class
- | |-- classFile02.class
- | `-- classFile03.class
- |-- tags/
- | |-- tagFile01.tag
- | |-- tagFile02.tag
- | `-- tagFile03.tag
- `-- web.xml
- When the WAR is built, JAR files are placed in its "lib" directory.
- All files in a WAR file are on the classpath, except for the WEB-INF directory and its associated files.
- When the EAR is built, JAR files are removed from the WAR's "lib" directory (if they exist), and placed in the EAR's "lib" directory. This action is described in the project's pom.xml file.
- JAR files are placed in the WAR's "lib" directory for hot deploy from NetBeans, but removed (if they exist), and placed in the EAR's "lib" directory for production deployment.
- You can have JAR files in both the WAR's "lib" directory and the EAR's "lib" directory ... but not when using the GlassFish appserver. GlassFish will not allow this for security reasons. Other appservers (e.g., JBoss, WebSphere, etc.) will allow this.
- You can have the same JAR file in the WAR's and EAR's "lib" directory, but this can/will lead to a classloader conflict.
- EAR
- An EAR (Enterprise ARchive) is a file format used by Java EE for packaging one or more modules into a single archive so that the deployment of the various modules onto an application server happens simultaneously and coherently. It also contains XML files called deployment descriptors which describe how to deploy the modules.
- EAR.ear
- |-- META-INF/
- | |-- MANIFEST.MF
- | `-- application.xml
- |-- lib/
- | |-- someLibraryJARFile01.jar
- | |-- someLibraryJARFile02.jar
- | `-- someLibraryJARFile03.jar
- |-- ejbModule.jar
- `-- webModule.war
- EJB JARs do not go into the EAR's "lib" directory, they go at the top-level of the EAR.
- GlassFish does not expose the "lib" directory JAR files raw classpath.
- EAR -> "lib" == JARs of resources only (ex: <AppName>Config.jar)
- In an EAR file:
- "lib" JARs can see other "lib" JARs
- top-level WAR files can see other top-level WAR files
- top-level WAR files can see "lib" JAR files
- "lib" JAR files CANNOT see top-level WAR files
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement