1 Reply Latest reply: Jul 4, 2011 12:58 PM by jschellSomeoneStoleMyAlias RSS

    ELFCLASS64 error when running the appplication


      I have read a lot of tutorials of making a "Hello World" JNI application.
      But I allways get
      Exception in thread "main" java.lang.UnsatisfiedLinkError: /home/Roxxor/JavaApps/libNativeExample.so 
      /home/Roxxor/JavaApps/libNativeExample.so: wrong ELF class: ELFCLASS64 (Possible cause: architecture word width mismatch)
      My JRE is 64bit and I compiled the shared file with 64bit support:
      g++ -m64 -shared -I/usr/java/jdk.1.6.0_17/include -I/usr/java/jdk.1.6.0_17/include/linux NativeExample.cpp -o libNativeExample.so -fPIC
      Where is the mismatch?

      Solved it. It seems that the JVM didn´t have support for 64 bit although, so I compiled the shared library with:
      g++ -m32 -shared -I/usr/java/jdk.1.6.0_17/include -I/usr/java/jdk.1.6.0_17/include/linux NativeExample.cpp -o libNativeExample.so -fPIC
      and then it worked.

      Strange, because when I print all java properties, the
      - java.vm.name states "Java HotSpot(TM) 64-Bit Server VM" and
      - sun.management.compiler prints "HotSpot 64-Bit Server Compiler"

      So, is it a 32 or a 64 Bit JDK I am working with?

      Edited by: Roxxor on 2011-jul-04 00:22