Java Classloader - how to reference different versions of a jar

前端 未结 5 1158
一个人的身影
一个人的身影 2020-12-03 07:28

This is a common problem. I\'m using 2 libraries A.jar and B.jar and these depend on different versions of the same jar.
Let\'s say tha

5条回答
  •  清歌不尽
    2020-12-03 08:06

    OSGi can fix this problem. An OSGi bundle is nothing more than a jar with additional metadata detailing versions. A bundle has a version number, and will detail version numbers (or ranges) of dependent jars.

    Take a look at this introductory Javaworld article for more information.

    To solve this without OSGi means having to ensure manually that you compile and run with compatible jars. As you've discovered that's not necessarily a trivial task. Since jars don't necessarily identify their versions, the only sure way to do this to record/compare checksums or signatures.

提交回复
热议问题