简体   繁体   中英

How to create JAR file with includes shared library(.so)

For one of my project I need to call native c code to my java class . For this I made following steps.

  1. In my java class I declared some native methods which are required for my project. ie

     public native String print(String pM,int len); public native int openPrint(); 
  2. I initiated library file like below

     static { System.loadLibrary("print"); } 
  3. After this I created header file with respect java code.

  4. created c file and implemented above methods in c

  5. after this I generated library file ie libprint.so using ndk-build

  6. library file is created successfully in libs->armeabi->libprint.so

  7. 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.

In Windows if the jar use a dll, you must copy the dll to the root folder inside the jar. After that the program will find it.

Try it, it maybe help you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM