- FAQ 94: What is a plug-in?
- FAQ 95: Do I use plugin or plug-in?
- FAQ 96: What is the plug-in manifest file (plugin.xml)?
- FAQ 97: How do I make my plug-in connect to other plug-ins?
- FAQ 98: What are extensions and extension points?
- FAQ 99: What is an extension point schema?
- FAQ 100: How do I find out more about a certain extension point?
- FAQ 101: When does a plug-in get started?
- FAQ 102: Where do plug-ins store their state?
- FAQ 103: How do I find out the install location of a plug-in?
- FAQ 104: What is the classpath of a plug-in?
- FAQ 105: How do I add a library to the classpath of a plug-in?
- FAQ 106: How can I share a JAR among various plug-ins?
- FAQ 107: How do I use the context class loader in Eclipse?
- FAQ 108: Why doesnt Eclipse play well with Xerces?
- FAQ 109: What is a plug-in fragment?
- FAQ 110: Can fragments be used to patch a plug-in?
- FAQ 111: What is a configuration?
- FAQ 112: How do I find out whether the Eclipse Platform is running?
- FAQ 113: Where does System.out and System.err output go?
- FAQ 114: How do I locate the owner plug-in from a given class?
- FAQ 115: How does OSGi and the new runtime affect me?
- FAQ 116: What is a dynamic plug-in?
- FAQ 117: How do I make my plug-in dynamic enabled?
- FAQ 118: How do I make my plug-in dynamic aware?
FAQ 106: How can I share a JAR among various plug-ins?
Suppose that plug-in A and plug-in B both use xmlparser.jar. In your workspace are two projects (for A and B), each containing a copy of the xmlparser.jar library. This is clearly not ideal: Two copies of the JAR are loaded at runtime, and classes from those JARs will not be compatible with each other, as they are loaded by different class loaders. (You will get a ClassCastException if you try to cast a type from one library into a type from the other library.)
Declaring xmlparser.jar as an external JAR does not work, as there is no easy way during deployment of your plug-ins to manipulate your plug-in’s classpath so that they can see the library. The best way to share libraries is to create a new plug-in that wraps the library you want to share.
Declare a new plug-in, C, to contain the library JAR, and make both plug-in A and plug-in B dependent on plug-in C. Make sure that plug-in C exports its library so other plug-ins can see it:
<runtime> <library name="xmlParserAPIs.jar"> <export name="*"/> </library> </runtime>
When you deploy these three plug-ins, they will all share the same library. Note that in some situations, sharing libraries between plug-ins is not possible. If two plug-ins require different or incompatible versions of the same library, they have no choice but to each have a copy of the library.
FAQ 104 What is the classpath of a plug-in?
FAQ 105 How do I add a library to the classpath of a plug-in?