I have created one OSGi plugin (Bundle) using eclipse File-->New-->Other-->Plug-in Project
called plugin 1.
I want to use a native .so
library in this plugin. I have added libtest_app_wrap1.so
at the root of my plugin project.
my project structure looks like below
And here is the manifest file
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
And this is the code of my Activator class
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!!");
}
}
I create jar file from plugin project using eclipse export feature. output jar file contains .so
library.
I don't get any exception or error when I call the System.loadLibrary("test_app_wrap1");
, but when I call the method test_app.foo();
it gives me UnsatisfiedLinkError
. test_app.foo()
is a jni method which is defined in .so
.
I am not getting any clue to resolve this error. Please help to get it resolve.
[Edit: Output bundle content]
Here is the content of the output jar