简体   繁体   中英

How do i conditionally load a library in java depending on the operating system?

I know for a fact that this question has to have been asked, probably multiple times. My apologies for asking again here, but I've been searching for information on this off and on for days, but I just can't find the relevant information. Thus, obviously, I'll be more than happy with a pointer to relevant info.

I'm using eclipse (oxygen) for a java project that I've started and made a lot of progress in, under Linux. I want to be able to work with this application under 'doze, too, however, and potentially other OSes, if the opportunity arises.

My application, under linux, has been using the apache creative commons compress library, in order to handle archival/compression in archives that it's using. These have been added in the eclipse project options, not by programatic means.

My question is this: once I locate an appropriate set of libraries, to be able to handle the different formats for archival and compression that I need to in 'doze, how do I selectively include the right set of libraries based on the operating system version? I know how to determine the OS, just not how to choose what libraries to utilize.

Any help, or pointers to previous postings that I know I've missed covering the same information, will be greatly appreciated. Thanks for your time and help on this matter!

您可以通过System.load()手动加载库,显然您可以在调用之前拥有所需的任何逻辑。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM