JNI issue on Linux: cannot open shared object file -
I have looked at this question here, tried to solve the proposed, but there is no success for me yet. There is quite a few Java experiences, but JNI did not do this on a long time ago, Linux ...
I am trying to get a simple HelloWell JNI app running on Linux.
Smaller Java file:
class hello {private original zero print (); Public stable zero main (string [] args) {new hello (). Print (); } Stable {System.out.println (System.getProperty ("java.library.path")); System.loadLibrary ("HelloWorld"); }} Small file:
#include & lt; Jni.h & gt; # Include & lt; Stdio.h & gt; #include "HelloWorld.h" JNIEXPORT Java_HelloWorld_print (JNIEnv * env, Jobked OBG) the zero {printf ( "Hello World! \ N"); Return; } has compiled the C file:
gcc -shared -Wall -fPIC Halovayrld- c / i / usr / lib / gcc / x86_64- included redhat -ellain / 3.4.3 / / -o libHelloWorld.so application to run as follows:
Java Halowald < / pre> or
Java Djava.library.path = / home / nxp40954 / jnitesting / HelloWorld but not good, a saying:
exception in thread "main" java.lang.UnsatisfiedLinkError: / home / nxp40954 / jnitesting / libHelloWorld so: /home/nxp40954/jnitesting/libHelloWorld.so: shared object file Can open The file or directory Is not it strange, because actually a / home / nxp40954 / Jnitesting / libHelloWorld.so file. Do anyone have any clues?
Execute this way:
export LD_LIBRARY_PATH = Java Halowald java.lang.UnsatisfiedLinkError is thrown when .so the file can not be loaded. The LD_LIBRARY_PATH variables * .so indicates extra space for viewing files.
I am 32 bit Ubuntu with Suraj Java. I was compiling like this:
gcc -shared -Wall -fPIC HelloWorld.c -i / usr / lib / jvm / java-6-sun-1.6.0.26 / included- I / usr /lib/jvm/java-6-sun-1.6.0.26/include/linux-o libHelloWorld.so
Comments
Post a Comment