For one of my project I need to call native c code to my java class
. For this I made following steps.
In my java class I declared some native methods which are required for my project. i.e
public native String print(String pM,int len); public native int openPrint();
I initiated library file like below
static { System.loadLibrary("print"); }
After this I created header file with respect java code.
created c file and implemented above methods in c
after this I generated library file i.e
libprint.so
usingndk-build
library file is created successfully in
libs->armeabi->libprint.so
whenever I run that java application it's giving error saying that
Exception in thread "main" java.lang.UnsatisfiedLinkError: no print in java.library.path
How do I solve this problem.?
I want to give this kind of application to other Android developers so that they can create this application without doing Native call and without creating libprint.so
file
It means I have to give my own API to application developer. For this I have to create JAR file. which includes java.class
, libprint.so
(shared library) and etc...
How to create JAR file which includes libprint.so
also..
I am doing all above stuffs in ubuntu using eclipse and open-jdk6.