问题
Does anyone know what the difference is between adding an appropriate JAR-file (eg. Apache XALAN) to a JRE's endorsed directory and adding it to the application's classpath?
Is it possible to take a jar-file that can be added to the endorsed lib and instead add it to the classpath?
回答1:
Tecnically you probaly can do that, but the difference is that the jar files in the endorsed directory are loaded by the bootstrap classloader, which is probably not the same classloader as the one that loads your jars from the classpath.
There is a classic XML problem with the Xerces and Xalan XML implementations which are out in the endorsed directory. Because newer applications sometimes require newer versions of both libraries, and the classes have the same names, there is a classpath problem.
You can replace the Xerces and Xalan libraries in the endorsed dir (backup your old ones!) but that can possibly screw up other applications which use the same JRE installation.
I've even seen this problem within 1 application where one library depends on one version, and another library depends on another version of xerces. Very troublesome, and there's no "general approach" to this, or at least none that I found.
There are some interesting articles easily found by Google on this, try to find one which best matches your situation or problem.
来源:https://stackoverflow.com/questions/380411/difference-between-classpath-and-endorsed-directory