What you might want to look at is the various
J2EE classloaders.
There are about 5 core classloaders that work for a J2EE application, and they work on a hierarchy. If you move a.jar into the path of one classloader, and b.jar onto the path of another classloader that is above a on the classloader heirarchy, you will always have consistent classloading behavior.
Still, I don't like having multiple versions on the classpath. It's ugly.
Here's a great article on J2EE classloaders. It might give you some ideas:
How J2EE Classloaders Work - Parent First and Parent Last and Stuff -Cameron McKenzie