views:

36

answers:

3

I'm developing a Java plugin for an existing Java program. The existing program uses a specific version of eclipse.uml2.* and my plugin does too. Unfortunately I need a newer version for my plugin.

In order to run the plugin, I need to export it into a Jar file (with all jars packed). Then the program executes it. But somehow the new eclipse.uml2.* seem to interfere with the program -> it crashes.

Is there a way to "separate" both versions of the jar files?

A: 

This will be difficult. You conceivably try to use class loader tricks to allow both versions of the eclipse.uml.* classes to be loaded in the same JVM. But as far as the JVM would be concerned they would be different sets of classes, and your plugin and the base java app wouldn't be able to exchange instances.

It is probably simpler (and less risky ... in terms of likelihood of success) to rebuild (and if necessary modify) either the base program or your plugin so that they both work with the same version of the eclipse.uml2.* classes.

Stephen C
+1  A: 

An approach will be to use a custom class loader in your application. This can very easily introduce bugs that are difficult to trace, so take care.

http://www.devx.com/Java/Article/31614/1954

saugata
+1  A: 

This is the exact problem OSGi tries to solve. Would it be feasible to rework the Java app to another plugin platform?

Thorbjørn Ravn Andersen