从OSGi Bundle调用本机方法时出现UnsatisfiedLinkError

我使用eclipse File-->New-->Other-->Plug-in Project创建了一个OSGi插件(Bundle) File-->New-->Other-->Plug-in Project称为插件1.我想在此插件中使用本机.so库。 我在我的插件项目的根目录中添加了libtest_app_wrap1.so

我的项目结构如下所示

插件项目结构

这是清单文件

 Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: JniTest Bundle-SymbolicName: JniTest Bundle-Version: 1.0.0.qualifier Bundle-Activator: jnitest.Activator Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Import-Package: org.osgi.framework;version="1.3.0" Bundle-NativeCode: libtest_app_wrap1.so; osname=linux; processor=amd64 

这是我的Activator类的代码

  package jnitest; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; public class Activator implements BundleActivator { public Activator() { System.loadLibrary("test_app_wrap1"); System.out.println("Library Loaded Successfully......."); } /* * (non-Javadoc) * * @see * org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) */ public void start(BundleContext context) throws Exception { try { test_app.foo(); } catch (Throwable tr) { tr.printStackTrace(); } } /* * (non-Javadoc) * * @see * org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) */ public void stop(BundleContext context) throws Exception { System.out.println("Goodbye World!!"); } } 

我使用eclipse导出function从插件项目创建jar文件。 输出jar文件包含.so库。

当我调用System.loadLibrary("test_app_wrap1");时,我没有得到任何exception或错误System.loadLibrary("test_app_wrap1"); ,但是当我调用方法test_app.foo(); 它给了我UnsatisfiedLinkErrortest_app.foo()是一个在.so定义的jni方法。

我没有得到解决此错误的任何线索。 请帮助解决它。

[编辑:输出包内容]

这是输出jar的内容

罐子输出

通过以下方式将jar添加到项目中:Project-> Properties-> Libraries-> Add Jar通过plugin.xml-> Runtime-> ClassPath section-> Add将jar添加到类路径

或使用以下方法添加jar

 java -Djava.library.path 

并通过以下方式validation:

 System.getProperty("java.library.path")