I have a class client. Java two jar1 & amp; Jar2 Now at the run time I want to decide how the client is loaded.
if (country == India) {// Load Client class jar 1} other { Load Client Clients from jar2
Can I do this ...
If 2 squares are the same package name, i.e. com.mycompany.Client, then you end up in a situation where it is somewhat arbitrary that what version of the customer is loading. It comes down, which is in the first grade. It is a jar hell situation.
This is a good condition to avoid, but if you have exactly the same versions of the same category, then there are several ways to do this. There is a way to use a custom customloader and the ClassLoder will know which version you need, there is not a small thing to do and it can be difficult to manage. The OSGI framework is an option to help manage this (it uses a custom classador under the hood), but I will not use it if you have an example of a class because it is another framework And maintains.
Bottom line: Avoid the situation if you can and at least take the path of resistance.
If classes have different package names, then Cassidyblow has given a good answer.
Comments
Post a Comment