1

I have developed a project with swing, maven with some native libraries. Now i have an issue with calling SO from java after generating jar from maven package. I included so in POM.xml. And it included that file inside jar.But it wont link both.

I had an error while executing jar like " Exception in thread "main" java.lang.UnsatisfiedLinkError: no projectso in java.library.path"

 <resources>
       <resource>
         <filtering>false</filtering>
         <directory>${project.basedir}/lib</directory>
         <includes>
           <include>my.so</include>
           <include>cv2.so</include>
         </includes>
       </resource>
   </resources> 

And also want to add library folder and export it into jar.Is there any way to do it?

praveenkumar s
  • 325
  • 4
  • 16

1 Answers1

1

Your native library path is not correct for your program to run. see Call c function from Java

use -Djava.library.path=/path/to/libs to set the path before executing the program.

use System.loadLibrary("HelloWorld") to set the path in runtime

please take look at the link I post again.

xxy
  • 1,058
  • 8
  • 14
  • Yaa, I did this in my code. Still i'm getting the same error after making jar – praveenkumar s Nov 09 '17 at 06:00
  • @praveenkumars print "java.library.path" in your log to make sure it's right – xxy Nov 09 '17 at 06:02
  • before built jar i'm getting the right path, after build the jar i'm getting the jdk lib path. How to resolve this? /home/hubino/torch/install/lib:/home/hubino/torch/install/lib::/usr/local/cuda-8.0/lib64:/home/hubino/Documents/software/cudnn/cudnn_5.1/lib64:/home/hubino/Videos/lib:/usr/java/packages/lib/amd64:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib – praveenkumar s Nov 09 '17 at 06:08
  • Do you have any idea for changing this library path in jar? – praveenkumar s Nov 09 '17 at 09:28