Hi,
I have tried a sample from JNI and tried to get the out put of c through java.I am posting the java and c code:
JNIDemo.java
Nativecode.c
I compiled the java program and created header file too.Then i have created library like
cc -o libnativecode.so -shared -I/usr/java/jdk/include -I/usr/java/jdk/include/linux Nativecode.c
Now libNativecode.so file is created in the dir /usr/java/jdk/include/linux.
Then I set the path environment variable to point the library file like
export LD_LIBRARY_PATH=/usr/java/jdk/include/linux:$LD_LIBRARY_PATH:
Then i run the java file like java JNIDemo.I am getting the following error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: libNativecode: libNativecode.so: cannot open shared object file: No such file or directory
at java.lang.Runtime._load(libgcj.so.7rh)
at java.lang.Runtime.loadLibrary(libgcj.so.7rh)
at java.lang.System.loadLibrary(libgcj.so.7rh)
at JNIDemo.<clinit>(JNIDemo.java:3)
at java.lang.Class.initializeClass(libgcj.so.7rh)
I think i am wrong in setting the library path.Please point out me where am i wrong and help me to solve this problem.
Thanks in Advance