目前,我在我的包的根目錄下有DLL文件(rfid.dll; cpl.dll; rfidtx.dll;)。 我製作一個Utility Bundle來保存jna.jar,並將com.sun.jna,com.sun.jna.ptr導出爲服務。關於在OSGi包內加載DLL(使用JNA)的問題
的清單有問題的包看起來是這樣的:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: ServiceImpl
Bundle-SymbolicName: osgi.mti.serviceImpl
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: ZTESOFT
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: osgi.mti.service,
org.osgi.service.component;version="1.1.0",
com.sun.jna,
com.sun.jna.ptr
Service-Component: OSGI-INF/component.xml
Bundle-NativeCode: rfid.dll;cpl.dll;rfidtx.dll;
osname=WindowsXP;
processor=x86
在我的代碼中,JNA接口被聲明爲:
public interface CLibrary extends Library {
CLibrary INSTANCE = (CLibrary) Native.loadLibrary("rfid",
CLibrary.class);
............
}
當我運行有顯示的一些異常消息。根異常是:
java.lang.UnsatisfiedLinkError: Unable to load library 'rfid'
那麼,我該如何解決這個問題呢?我希望有一個人可以幫助我。
我問完全相同的問題,有一個簡單的答案:[在OSGi包中加載DLL(使用JNA)](http://stackoverflow.com/questions/1375550/load-dll-using-jna-inside- an-osgi-bundle) – 2010-08-22 15:42:02