This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I am working on eclipse. I have 2 jar files with the same name. One is the older version and one is the newer version. So,both these jar files have the classes with the same name but methods signatures differ. I want to use methods from both these jars ON THE SAME OBJECT. When I add both these libraries to the eclipse project as referenced libraries, the program is only accepting methods from the first jar file and it is showing errors when I use the methods from the second jar file. What can/should I do now? Both these jars have compiled classes in them.
IMO that's a really bad idea, and it's rare it's necessary.
That said, you'll have to shadow one of the jars somehow--there are programs on the web that can do this for you in a variety of ways. On the very rare occasions I've had to do this I usually use something like jarjar to create a new jar of the library that has dependencies on the old jar. The new jar contains both the library and the old version of the jar.
If *your* code needs to use both versions then I'd recommend rewriting your code.
Joined: Dec 18, 2008
Thanks David for the reply.
I am sorry.I didnot get you.Can you be more clear.
Not really; that's about as simple as I can make it.
Wanting to use multiple versions of the same classes is a recipe for trouble and it should be avoided whenever possible--which is almost always.
When it's *not* avoidable, you can create a jar file that contains both its own code and a "shadowed" version of the library that's causing the conflict. One tool to do this is jarjar; there are others, and it's pretty easy to write your own (but I wouldn't bother, if I were you).
If *your* code, in other words, if *you* are writing code that depends on multiple versions of the same classes, then you should rewrite your code--it's simply not worth the pain, in my opinion.