Search code examples
javaamazon-web-servicesamazon-s3jar

Use 2 versions of same Lib


Is it possible to use the same lib with different versions ?

The thing is:

i have the httpclient-4.0.1 into my application in the WEB-INF/lib directory.

I made an API for the Amazon S3 service, which use the httpclient-4.1.1. But i don't want to update my application library to use the newer version, because i don't have enough time to test and garantee that the application will run properly. So, is there a way, that my API i`ve made (actually a jar) to use the httpclient-4.1.1 without need to upgrade the library of my application (4.0.1)?


Solution

  • you cannot use 2 versions of same Lib in the same class loader; but you can use different class loader to load th different versions. For example, you can use a sub classloader to loader httpclient-4.0.1, and shield 4.1.0 in the super class loader.