简体   繁体   English

在Eclipse中动态加载库

[英]Dynamically Loading Libraries in Eclipse

I'm currently working on a java project in eclipse that uses 64-bit SWT libraries. 我目前正在使用64位SWT库的Eclipse中开发一个Java项目。 A lot of the computers this program might be used on have 32 bit operating systems, so to avoid making a 32-bit and a 64-bit version, I want to explore dynamically loading a 32-bit or 64-bit SWT library depending on the JRE being used at the time. 该程序可能在很多计算机上使用32位操作系统,因此,为了避免制作32位和64位版本,我想探索动态加载32位或64位SWT库的方法,具体取决于当时正在使用的JRE。

I found some references to using ClassLoader, ServiceLoader, and similar objects, however I'm not sure how that would fit in with eclipse's structure, and if eclipse's structure even allows for this type of loading in the first place. 我找到了一些有关使用ClassLoader,ServiceLoader和类似对象的参考,但是我不确定这与eclipse的结构如何匹配,并且如果eclipse的结构是否首先允许这种类型的加载,我也不知道。 Additionally, I am unsure how to check which jvm is being used inside the code, which I assume would be a prerequisite for knowing which SWT libraries would load correctly. 另外,我不确定如何检查代码中正在使用哪个jvm,我认为这将是知道哪些SWT库正确加载的先决条件。

If you guys would be able to provide any suggestions or directions in which to focus my research, that would be great. 如果你们能够提供任何建议或方向来关注我的研究,那将很棒。 I'm currently pretty unsure on how to proceed. 我目前不确定如何继续。

Thanks! 谢谢!

This SO question has some answers with code that you could pilfer and adjust to your needs. 这样的问题有一些答案,您可以窃取并适应您的需求。 By the way, Eclipse itself (actually, the OSGi runtime) could handle this for you, if you were doing an RCP app. 顺便说一句,如果您正在执行RCP应用程序,则Eclipse本身(实际上是OSGi运行时)可以为您解决此问题。

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

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