简体   繁体   English

如何根据操作系统有条件地在Java中加载库?

[英]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. 我在Linux下使用eclipse(氧气)启动了一个Java项目,并在该项目上取得了很多进步。 I want to be able to work with this application under 'doze, too, however, and potentially other OSes, if the opportunity arises. 如果机会出现的话,我也希望能够在'doze'下使用此应用程序,并可能在其他OS下使用。

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. 在Linux下,我的应用程序一直在使用apache Creative Commons压缩库,以便处理正在使用的档案中的存档/压缩。 These have been added in the eclipse project options, not by programatic means. 这些已添加到eclipse项目选项中,而不是通过编程方式添加。

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? 我的问题是:一旦找到合适的库集,以便能够处理“打ze”时需要的各种存档和压缩格式,如何根据操作系统版本有选择地包括正确的库集? ? 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()手动加载库,显然您可以在调用之前拥有所需的任何逻辑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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