Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I have started to build a java service which incorporates JNA to load a native C/C++ lib and i want to run the java service on the Raspberry PI aka arm platform. I have successfully built a stable ground of the service and it runs on both Windows7 and linux-amd64/debian but.. on the RPI platform i get the above stated error: Exception in thread "main" java.lang.UnsatisfiedLinkError: JNA native support (/com/sun/jna/linux-arm/libjnidispatch.so) not found in resource path

On the RPI i have done the following: * Installed both openjdk7 and java8 beta with arm hard float support. * Installed libjna-java lib.

Following are set:

root@pisces:/opt/TellstickReplay# java -version
java version "1.8.0-ea"
Java(TM) SE Runtime Environment (build 1.8.0-ea-b36e)
Java HotSpot(TM) Client VM (build 25.0-b04, mixed mode)
root@pisces:/opt/TellstickReplay#

LD_LIBRARY_PATH

root@pisces:/opt/TellstickReplay# echo $LD_LIBRARY_PATH
/opt/lib/jna

CLASSPATH

root@pisces:/opt/TellstickReplay# echo $CLASSPATH
/usr/lib/jna

None of the settings seems to satisfy JAVA with JNA support. I have even tried to export both jna.jar and linux-arm.jar into the project in Eclipse and all together rebuild the jars into the exported jar still getting the same error. The exported jar has been tested successfully on both windows and linux so the jar file is working.

I have also tried to just use CLASSPATH in the Manifest in the jar file but with no success. I have also tried to explicitly load the libjnidispatch.so from the absolute path but JAVA then starts to complain that it cannot find the file to libjnidispatch.so even that the path is 100% correct.

So.. does anyone know HOW to correctly get JNA support on the Raspberry PI platform to work?? Please, im getting tremendously frustrated and soon giving up hope to fix this..

Where is libjnidispatch.so on your system? If it's not on your system, JNA will attempt to unpack it from jna.jar from the indicated resource path. If it's not there either, you'll get the UnsatisfiedLinkError.

It's recommended that you explicitly install libjnidispatch.so on your system where possible; the jna.jar bundling is mostly there to facilitate usage on the more common desktop platforms.

linux-arm.jar contains the most recent build of libjnidispatch.so, but only WebStart knows how to automatically load the native from a jar like that. If you unpack it into /opt/lib/jna (or elsewhere on LD_LIBRARY_PATH), you should avoid the link error.

the libjnidispatch.so is both in the CLASSPATH, LD_LIBRARY_PATH and on the filesystem in /usr/libs/jna. – Pär Fransman Feb 1, 2013 at 20:17 The error message indicates that JNA has tried to unpack it from jna.jar after unsuccessfully loading via System.loadLibrary(). You can set the system property jna.boot.library.path to /usr/libs/jna, but you shouldn't have to if LD_LIBRARY_PATH already includes that path (note that in your question you have it set to /*opt/lib*/jna, which will result in an error if the library is actually in /*usr/libs*/jna). – technomage Feb 1, 2013 at 20:37 You mention System.loadLibrary() though i have read about JNA using Native.loadLibrary() but looking through jna i can´t find System.loadLibrary(). Is there a significant difference between these two?? – Pär Fransman Feb 1, 2013 at 20:59 Also is there a Raspbian image that have JNA working out of the box? I have been searching for a solution for this for so long i cant really motivate finding the source for this. – Pär Fransman Feb 1, 2013 at 21:24 I found the problem. JNA.jar was actually missing libjnidispatch.so inside the jna.jarso i just build jna.jar with Ant on the Raspberry Pi with openjdk6 and that solved the problem. Its strange though that linking with -Djna.boot.librar.path=/path/to/libjnidispatch.so still got the UnsatisfiedLinkError. Oh well, it works now =) Thank you very much for your patiance and input!! – Pär Fransman Feb 2, 2013 at 18:25

I am re-compiling Apache Spark for RPI2 and I've spent a couple of days to fix the issue. Then I've found the easiest possible solution. All you need to have is a libjnidispatch.so link in your default JVM's native lib path.

sudo -s ln -s /usr/lib/arm-linux-gnueabihf/jni/libjnidispatch.so /usr/lib/jvm/default-java/jre/lib/arm/libjnidispatch.so
                It almost worked and what I have discovered is that Elasticsearch 7.1.0 needs libjna-jni at least 5.2.0 andd the latest version for Raspberry Pi is 4.2.2
– Ken Ingram
                May 23, 2019 at 1:02
                The solution that worked for me was finding the relevant libjni.*.so library file and adding it to the jna.x.x.ja file.
– Ken Ingram
                May 23, 2019 at 2:57
  • sudo apt-get install libjna-java
  • get the installed jar /usr/share/java/jna.jar
  • Install jna.jar as a maven dependency
  • They worked to me...

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.