What does “Native library location” entry do in Eclipse?

倖福魔咒の 提交于 2020-12-02 12:04:59

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!