Search code examples
javajava-native-interface

Java native library architecture depend on JVM or OS?


I want to load native library to Java program, which is fine but I don't know which architecture should I load. If I'm running on x64 and I have a x64 JVM I will load 64 bit library but If I will run on x86 JVM on x64 what I should load ? It should be based on OS or JVM ?

Thank you


Solution

  • The "bitness" of the native library must be the same as that of the JVM.

    If you are using a 32-bit JVM, you need a 32-bit native library (no matter if the OS is 32-bit or 64-bit).

    If you are using a 64-bit JVM, you need a 64-bit native library.