Moin.
es ist mein erster Versuch mit JNI also weist mich auch auf offensichtliches hin:
Ein Example aus dem Netz produziert folgenden Fehler:
Exception in thread „main“ java.lang.UnsatisfiedLinkError: /mnt/win_e/java-jni/c++/libhello.so: /mnt/win_e/java-jni/c++/libhello.so: ELF file’s phentsize not the expected size
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1480)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1404)
at java.lang.Runtime.loadLibrary0(Runtime.java:772)
at java.lang.System.loadLibrary(System.java:832)
at HelloWorld.(HelloWorld.java:6)
at Main.main(Main.java:3)
Kompiliert wurde es mit
gcc -c -I . HelloWorldImpl.cc -o libhello.so
Die Meldung „ELF file’s phentsize not the expected size“ sagt mir garnichts (kann nicht viel C/C++). Die Datei an sich scheint er schon zu finden, die dazu passende Exception hatte ich auch schon.
Helloworld.java lädt einfach nur in einem static-block die lib, und Main.java ruft nur einen native-Methode in Helloworld.java auf.
HelloWorld. sagt mir dass Main nicht bis zum Anrufen der Methode kommt.
was nun ?