Search code examples
java32bit-64bitjnaelf

Running a mix of 32 and 64 bit native libraries in a Java application


We are developing a desktop Java application for Linux that accesses a series of peripherals (both USB and Serial port preripherals) using native .so libraries. Some vendors only make available 32 bit libraries and some others only make the 64 bit version available. As we need all peripherals to operate in our application, we have to find a way to run both architectures.

We are using JNA to connect to the native libraries in our Linux filesystem. When we attempt to access a 32 bit library while running our software under a 64bit JRE we get the following error message:

java.lang.UnsatisfiedLinkError: /usr/lib/jni/libsatprotocol.so: wrong ELF class: ELFCLASS32

Is there any way of running both architectures in a single JRE? Can we add certain 32 bit JRE libs to our 64 bit JRE? Would accessing the native libraries in a different way work?


Solution

  • Is there any way of running both architectures in a single JRE?

    No. They use different data models.

    See https://en.wikipedia.org/wiki/64-bit_computing#64-bit_data_models