[resolved]JNI C library not found [message #1783731] |
Fri, 16 March 2018 11:39 |
Jim Anderson Messages: 109 Registered: October 2014 |
Senior Member |
|
|
I have just started trying to use JNI to call some existing C programs from Java. In my shell scripts I have been able to make calls to the C-library, but I am getting jibberish as output and I need to do some debugging. From the terminal, my java command is:
java -Djava.library.path=${HOME}/prog/java/webapps/lib bfs.createPages.CinterfaceNameTable >& ./bfs/createPages/createpage3.out
The C library, 'libbfsmem.so', is in ${HOME}/prog/java/webapps/lib and is found when run as a terminal command line.
I set up for debugging by bringing up 'run --> Debug Configurations' and then selecting the 'Arguments' tab and entering:
-Djava.library.path=/home/jja/prog/java/webapps/lib CinterfaceNameTable
in the 'Program Arguments' box.
When I debug in Eclipse (Oxygen eclipse4.7_java), I get an error message:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no bfsmem in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at bfs.createPages.CinterfaceNameTable.<clinit>(CinterfaceNameTable.java:8)[/ALIGN][ALIGN=center]
Is there an alternate way to specify 'java.library.path' in Eclipse?
Jim A.
I just did a search on setting 'java.library.path' and found this link:
https://stackoverflow.com/questions/957700/how-to-set-the-java-library-path-from-eclipse#958074
My apologies, I should have done that search first.
Jim A.
I took a look at the link above and found in one of the comments that to set 'java.library.path', the -D option must be passed as an argument to the JVM. I had passed it as a program argument. That makes sense and it works!
[Updated on: Fri, 16 March 2018 13:40] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03981 seconds