I am working on a new desktop application using Eclipse Rich Client Platform (RCP). Eclipse RCP applications are comprised of plugins. The plugins are not any ordinary old plugins. They are Open Standard Gateway Initiative (OSGI) plugins.
One feature of OSGI plugins is classpath separation. One plugin can be running dom4j 1.5 and another dom4j 1.6, and there is no conflict. A nice idea. Unfortunately, a combination of an extraordinarily poor user interface in the Eclipse IDE coupled with a classloader that goes out of its way not to load classes, makes it very difficult for the newly initiated to get going. While I was away at OSCON2005, a developer on the project spent 8 full work days trying to figure out how to get our plugin to a load classes from a jar. While I was at OSCON I met Scott Delap. Scott is the maintainer of clientjava.com and knows a lot about RCP. Having taken a quick look at the problem myself and finding no documentation on to get the Eclipse IDE to do the right magic I called Scott. He helped through a fairly involved process, and one that is dependent on order and I was then able load jars! With agreement from Scott, I am making the HOWTO available below. It covers:- Loading classes from jars.
- Exporting classes to make them visible to other plugins.
- Swapping in another classloader to load resources.