I have two java projects Test1 and Test2. Test1 has a library lib added to it in its eclipse Java Build Path. Test2 has a jar added in its build path.
Test1 Test2
/src /src
lib Referenced Libraries
x-1.1.jar a.jar
y.jar x-1.2
z
The code in Test1 calls functions/classes of y.jar which has dependency on x-1.1.jar. I don't know what functions/classes of x-1.1.jar are used by y.jar as I don't have source for the jars. Similarly Test2 calls functions/classes of z package of a.jar which have dependency on x-1.2 verion of jar.
Now I have a Test project where I need both the projects Test1 and Test2
Test
/src
Test1 code
Test2 code
some other code which uses Test1 as well as Test2 libraries
lib
x-1.1.jar
y.jar
Referenced Libraries
a.jar
x-1.2
z
Now when I run the Test project I get into jar-hell situation. Two approaches used here by my research are:
- Classpath: Problem with this approach is that since both the library/jar for Test1, Test2 are added to the eclipse Java Build Path, only the first loaded version of the x.jar is accessed and Test2 code breaks even on using classloader.
- osgi: Problem with approach is that I am able to export only packages in the src folder of Test1 and Test2 from the osgi bundle, not the one's which are referenced by the project. But the Test project has code which uses Test1 and Test2 libraries.
Hope I am clear enough. Any help is greatly appreciated. Thanks in advance.
Adding more information to the question: I have to use two different java sdks in my project which have bundled different jar files. Conflicting ones are:
jar file Test1 ver Test2 ver
org.apache.commons.codecs 1.3 1.6
org.apache.commons.logging 1.1.1 1.1.1
org.apache.log4j 1.2.7 1.2.15
httpclient 4.1.1 4.0.3
httpcore 4.1 4.1.4
What can be possible ways to do this?