Reputation: 161
I am working on a project in which for few functionalities POI 2.5 version jars is being used and i have develop a new functionality for which i require POI version 3.10 jars so now the issue is that previous functionality is not working properly as it is working perfectly on poi 2.5 version jar
now if i keep both the versions of poi jars in my class path is there any way by which only for my classes i can call poi 3.10 version explicitly and for the previous functionality poi 2.5 version is being called
by default if i keep both the versions of poi jars then always the call goes in poi 2.5 versions of jar so i want for my class say class abc explicitly poi 3.10 version is being called
Please advise can i use class loaders explicitly here and also please advise is it possible if i can create the object of class dynamically also
class ABC
{
//version of poi 3.10 being called here
HSSFWorkbook workbookXls = new HSSFWorkbook();
}
class def which is being using earlier version of POI 2.5
class DEF
{
//version of poi 2.5 being called here
HSSFWorkbook workbookXls = new HSSFWorkbook();
}
Upvotes: 3
Views: 786
Reputation: 1661
Yes this can be done, loading each jar from a different classloader.
You can also refactor one the jars to change its packages and avoid collisions. This can be done automatically if your are using maven with the jar-jar MOJO.
Upvotes: 1