关注this问题。
我使用Bundle-NativeCode
标头来指定应该由插件加载的本机库
当库与加载它们的代码(System.loadLibrary
)位于同一个插件中时,它可以正常工作。但是,当我尝试将库放在单独的插件片段中时,System.loadLibrary
会失败并显示UnsatisfiedLinkError
。
主机插件的清单(当主机插件中的库时):
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Jni
Bundle-SymbolicName: com.ebar.workmode.jni
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: com.ebar.workmode.jni.Activator
Bundle-Vendor: EBAR
Require-Bundle: org.eclipse.core.runtime,
org.slf4j.api,
javax.inject;bundle-version="1.0.0",
com.ebar.workmode.contracts;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Export-Package: com.ebar.workmode.jni
Eclipse-ExtensibleAPI: true
Bundle-NativeCode: native/ipcs.dll ; native/ipcs_tcpip_plugin.dll ; osname=win32
插件片段的清单:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: workmode JNI win x86
Bundle-SymbolicName: com.ebar.workmode.jni.windows.x32;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: EBAR
Fragment-Host: com.ebar.workmode.jni;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-NativeCode: native/ipcs_tcpip_plugin.dll ; native/ipcs.dll ; osname=win32
Activator.start
主机插件:
@Override
public void start(BundleContext bundleContext) throws Exception {
System.loadLibrary("ipcs");
System.loadLibrary("ipcs_tcpip_plugin");
}
从主机插件中删除Bundle-NativeCode
标头时出现的错误:
java.lang.UnsatisfiedLinkError: no ipcs in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at com.ebar.workmode.jni.Activator.start(Activator.java:34)
at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:771)
at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:1)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:764)
... 102 more
build.properties
)为什么它没有工作以及如何使主机插件从插件片段加载本机库?或者,有没有办法让插件片段加载其库?