java - Finding a way to load appropriate jars in different OSs as per requirement -


this discussion involves getting way load different jars in different operating systems.

case scenario

i working on specific os known nsk. unix flavour , powers hp nsk servers. running 1 of middleware app ( java application) on nsk. requirement make app off-platform. i.e. must work in other platforms linux or windows well.

to implement this, introduced 1 more jar. need introduce logic where-in jvm must load appropriate jar @ runtime (jar1 on nsk , jar2 on other non-nsk platform). used following logic implement:

code:

if (system.getproperty(os.name).equals("nsk"))      load jar1 else       load jar2 

the above code works fine until hit 1 of security exceptions "securityexception" in getproperty api used above. tells user running app not have necessary permission use getproperty(). so, above logic goes toss here.

is there way tackle exception , still able find out os details , load correct jar? or better, there better logic implement same?

please refer below link more details getproperty(..)

http://docs.oracle.com/javase/7/docs/api/java/lang/system.html

thanks in advance

regards, pabitra

given java platform independent , loads classes use, have 1 jar has need , load class appropriate platform.

doing suggest requires sub class loader add complexity doesn't appear needed.

if can't access system property can actively test library , see 1 work on system. sure there method or class working in 1 case not other or wouldn't need 2 sets of code.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -