问题
If adding user-defined library in Eclipse, one has an ability to set "Native library location". This field allows to enter some directory path.
When does this path plays a part?
回答1:
Eclipse uses this information to build the java.library.path
when it launches a Java program.
Background: Some Java frameworks depend on native code. This code usually comes in the form of a native shared library (*.so, *.dll). In Java, you can see methods with the attribute native
. The code will load the shared library using System.loadLibrary()
.
In order to make the code independent of absolute paths, you just pass the name of the shared library to System.loadLibrary()
. The System property java.library.path
is then used to determine in which directories the VM should look to locate the file.
Together with Eclipse's feature to define user libraries, you can easily add Java libraries that depend on native code to your projects.
回答2:
Are you referring to the Java Build Path configuration?
You may need this location if your project uses JNI or JNA. This directory is the location of native code (e.g. a Windows DLL written in C.)
I don't think this information is actually required until you try to run the code. You could provide this information via the Run Configuration for example.
来源:https://stackoverflow.com/questions/19768008/what-does-native-library-location-entry-do-in-eclipse