Reputation:
Say I need (its required) to use fizz-1.0.jar
and buzz-2.3.2.jar
in my Java project. Now, fizz-1.0.jar
depends on foo-0.1.35.jar
, and buzz-2.3.2.jar
depends on foo-4.2.17.jar
.
foo-0.1.35.jar
contains a Widget
class like so:
public class Widget {
public int doSomething(int x) {
return x++;
}
}
foo-4.2.17.jar
contains a heavily modifed version of Widget
:
public class Widget {
public Meh makeStuff() {
return new Meh();
}
}
Unfortunately, both fizz-1.0.jar
and buzz-2.3.2.jar
make heavy use of both versions of Widget
.
I can't just blindly add both versions of foo-x.y.z.jar
to the classpath, because whichever Widget
gets loaded first will only work for either fizz-1.0.jar
or buzz-2.3.2.jar
.
What are my options here? Remember I must have both fizz-1.0.jar
and buzz-2.3.2.jar
, and must satisfy all of their transitive dependencies.
Upvotes: 0
Views: 107
Reputation: 138
I would recommend that you use a framework which distinguishes class loads. E.g. OSGi framework. Then you can create 2 bundles - one with the fizz implementation and one with the buzz implementation. They both can contain their dependent libraries which do not conflict anymore because they are loaded from 2 different classs loaders.
Example osgi containers or "Eclipse Equinox" and "Apache Felix" but there are more.
Hope that helps.
Upvotes: 1