loading class from latest version of library jar with URLClassloader
I have 2 versions of jar file (plugins1.0.jar and plugins2.0,jar) in same folder and trying to load Class from these jar files dynamically using URLClassloader. I want to ensure that the class should be loaded from latest version of jar file.
How can 开发者_开发知识库i achieve this ?
Thanks in advance
You will need to construct your list of urls in such a way that plugins2.0.jar
occurs before plugins1.0.jar
. But generally it's a bad idea as other classes may have conflicting versions loaded.
From Java docs
The URLs will be searched in the order specified for classes and resources after first searching in the parent class loader.
精彩评论