Search code examples
javalinuxjava-native-interface

Compile JInput on ARM


I have a Raspberry Pi 2, and an arduino pro micro set up as a Joystick. On the Pi i have a java application that runs well on a PC with both Linux and Windows with the arduino joystick connected. But as soon as I start running the program on the pi I get an error message like:

`Failed to load library:" /libjinput-linux64.so: /libjinput-linux64.so`

After some googling around i find that the problem is that the Jinput library is not compiled to run on ARM processors:

JInput on RaspberryPi

So far so good, but this far I could not find a solution as to how I get the .so file compiled to run on the arm processor. I guess it is somewhat trivial for someone with the knowledge, since the file is easily decompiled and the project is open source.

But I have been stuck at this stage for the last 1½ month. Any help as to how to compile it where to find the files that are to be compiled and such, or alternatively finding an already compiled file for the raspberry pi 2 would be helpful.


Solution

  • Not a direct answer about how to compile JNI libraries, but there appears to be a pre-compiled version available on Raspbian:

    > apt search jinput
    Sorting... Done
    Full Text Search... Done
    libjinput-java/stable 20100502+dfsg-7 all
      Java Game Controller API
    
    libjinput-java-doc/stable 20100502+dfsg-7 all
      Java Game Controller API (javadoc)
    
    libjinput-jni/stable 20100502+dfsg-7 armhf
      Java Game Controller API (jni)
    

    So the solution may be to just apt install libjinput-java; this will probably include the -jni package as a dependency (see here).