0

I could understood that Desktop applications in Java doesn't have a pre-defined relative path for jar (library) files inclusions. It already have a CLASS_PATH env var.

But what I couldn't understood why EJB modules doesn't such feature... (Web App has!- throw WEB-INF/lib)

Muhammad Hewedy
  • 29,102
  • 44
  • 127
  • 219

1 Answers1

1

Here are two excerpts from the Java EE specification:

A JAR format file (such as a .jar file, .war file, or .rar file) may reference a .jar file or directory by naming the referenced .jar file or directory in a Class-Path header in the referencing JAR file’s Manifest file. The referenced .jar file or directory is named using a URL relative to the URL of the referencing JAR file. The Manifest file is named META-INF/MANIFEST.MF in the JAR file. The Class-Path entry in the Manifest file is of the form

Class-Path: list-of-jar-files-or-directories-separated-by-spaces

A .ear file may contain a directory that contains libraries packaged in JAR files. The library-directory element of the .ear file’s deployment descriptor contains the name of this directory. If a library-directory element isn’t specified, or if the .ear file does not contain a deployment descriptor, the directory named lib is used. An empty library-directory element may be used to specify that there is no library directory. All files in this directory (but not subdirectories) with a .jar extension must be made available to all components packaged in the EAR file, including application clients. These libraries may reference other libraries, either bundled with the application or installed separately, using any of the techniques described herein.

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255
  • So, I understood that by default `web module` and `ear app` have `WEB-INF/lib` and `lib` dir respectively. but `ejb module` doesn't have. – Muhammad Hewedy Jun 27 '12 at 13:26
  • 1
    An ejb module has every jar from the lib directory of the ear in its classpath. Those are shared by all the other EJB modules and web modules. If you want to put a library jar in the classpath of just one ejb-module, use the Class-Path manifest of the ejb-module jar to specify this dependency. – JB Nizet Jun 27 '12 at 13:30
  • Thanks, I got it. But I think it will be more helpful if you summarize your answer as the first line of your answer followed by excerpts form specs. – Muhammad Hewedy Jun 27 '12 at 16:09