Advertisement
NoSalt

JAR - WAR - EAR

Apr 13th, 2012
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.27 KB | None | 0 0
  1. JAR
  2. 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.
  3.  
  4. JAR.jar
  5. |-- META-INF/
  6. | |-- MANIFEST.MF
  7. | `-- INDEX.LIST
  8. |-- classFile01.class
  9. |-- classFile02.class
  10. |-- classFile03.class
  11. `-- resources/
  12. `-- images/
  13. |-- imgFile01.tiff
  14. `-- imgFile02.tiff
  15.  
  16. WAR
  17. 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.
  18.  
  19. WAR.war
  20. |-- index.html
  21. |-- resources/
  22. | |-- file01.css
  23. | |-- file02.css
  24. | |-- file.js
  25. | `-- images/
  26. | |-- image01.jpg
  27. | |-- image02.gif
  28. | `-- image03.png
  29. |-- jspFiles/
  30. | |-- jspFile01.jsp
  31. | |-- jspFile02.jsp
  32. | `-- jspFile03.jsp
  33. `-- WEB-INF/
  34. |-- lib/
  35. | |-- library01.jar
  36. | |-- library02.jar
  37. | `-- library03.jar
  38. |-- classes/
  39. | |-- classFile01.class
  40. | |-- classFile02.class
  41. | `-- classFile03.class
  42. |-- tags/
  43. | |-- tagFile01.tag
  44. | |-- tagFile02.tag
  45. | `-- tagFile03.tag
  46. `-- web.xml
  47.  
  48. When the WAR is built, JAR files are placed in its "lib" directory.
  49. All files in a WAR file are on the classpath, except for the WEB-INF directory and its associated files.
  50.  
  51.  
  52. 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.
  53. 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.
  54. 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.
  55. 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.
  56.  
  57.  
  58. EAR
  59. 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.
  60.  
  61. EAR.ear
  62. |-- META-INF/
  63. | |-- MANIFEST.MF
  64. | `-- application.xml
  65. |-- lib/
  66. | |-- someLibraryJARFile01.jar
  67. | |-- someLibraryJARFile02.jar
  68. | `-- someLibraryJARFile03.jar
  69. |-- ejbModule.jar
  70. `-- webModule.war
  71.  
  72. EJB JARs do not go into the EAR's "lib" directory, they go at the top-level of the EAR.
  73. GlassFish does not expose the "lib" directory JAR files raw classpath.
  74. EAR -> "lib" == JARs of resources only (ex: <AppName>Config.jar)
  75. In an EAR file:
  76. "lib" JARs can see other "lib" JARs
  77. top-level WAR files can see other top-level WAR files
  78. top-level WAR files can see "lib" JAR files
  79. "lib" JAR files CANNOT see top-level WAR files
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement