To load your own library in java, you can use one of the following methods:
Using System.load
You can use the System.load(String filename) function to load the 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") .
Using System.loadLibrary
Alternatively, you can use the System.loadLibrary(String libName) function to load your own library. This method is system dependent and requires 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 the java argument.
Alternatively, since you are trying to use Eclipse , you can also specify this path as follows: Right-click on the project> Properties. Then select the Java Build path and go to the "Source" tab, here, if you expand the source folder, you can set the Native library folder that defines the path of your native library:

Since this call is system-dependent, note that the parameter libName System.loadLibrary(String libName) not the name of the native library directly. On MAC OS X (it differs from other OSs), it uses the lib prefix and the .dylib suffix on libName , so you must use SomeNative as libName .
Summarize, for example, to load /System/libraries/libSomeNative.dylib , you must specify java.library.path=/System/libraries/ , as described above, and make a call to System.loadLibrary("SomeNative") .
source share