JAR hell is
used to describe all the various ways in which the classloading process can end
up not working.Three ways JAR hell can occur are:
- A developer or deployer of a
Java application has accidentally made two different versions of a library
available to the system. This will not be considered an error by the
system. Rather, the system will load classes from one or the other
library. Adding the new library to the list of available libraries instead
of replacing it, may see the application still behaving as though the old
library is in use, which it may well be.
- Two libraries (or a library
and the application) require different versions of the same third library.
If both versions of the third library use the same class names, there is
no way to load both versions of the third library with the same
classloader.
- The most complex JAR hell
problems arise in circumstances that take advantage of the full complexity
of the classloading system. A Java program is not required to use only a
single "flat" classloader, but instead may be composed of
several (potentially very many) nested, cooperating classloaders. Classes
loaded by different classloaders may interact in complex ways not fully
comprehended by a developer, leading to
Note : Using
metadata in the JAR manifest, JAR files
(called bundles) are wired on a per-package basis. Bundles can export packages,
import packages and keep packages private, providing the basic constructs of
modularity and versioned dependency management.