I am trying to install a robot simulation software called V-Rep where to remotely simulate the robots, I need to have remoteApi.java
and remoteApiJava.dylib
files. I can't seem to figure out how to use the dylib file.
the error I get when I build the project:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no remoteApiJava in java.library.path
I tried running the dylib file directly in terminal, didn't work.
I placed it in /projectPath/lib/
, and added it as a build path in eclipse, didn't work
I also tried setting up the environment variable in run config, DYLD_LIBRARY_PATH = /projectPath/lib/
didn't work either.
What did I do wrong there?
To load a native library in java you can use one of these approaches:
You can use System.load(String filename)
function to load a library directly from the file system, you must specify the absolute path name of your native library. For example System.load("/System/libraries/libSomeNative.dylib")
.
You can alternatively use System.loadLibrary(String libName)
function to load a native library. This method is system dependent and require that
you specify java.library.path
with the paths where your native library is located. In your case you can use -Djava.library.path=/path/toNativeLib/
as a java argument.
Alternatively since you're trying with Eclipse you can specify also this path in the follow way: Right click on project > Properties. Then select Java Build path and click on Source tab, here if you expand your source folder you can set the Native library location specifying the path of your native library:
Since this call is system dependent note that libName
parameter of the System.loadLibrary(String libName)
is not the native library name directly. In MAC OS X (it works diferent on others OS) it use the lib
prefix and the .dylib
suffix on the libName
, so to specify libSomeNative.dylib
you've to use SomeNative
as libName
.
Summarize, for example to load /System/libraries/libSomeNative.dylib
you've to specify java.library.path=/System/libraries/
as explained above and make a call to System.loadLibrary("SomeNative")
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With