“本地库位置”是什么?入门在Eclipse中做? [英] What does "Native library location" entry do in Eclipse?
问题描述
如果在Eclipse中添加用户定义的库,则可以设置本机库位置。此字段允许输入一些目录路径。
If adding user-defined library in Eclipse, one has an ability to set "Native library location". This field allows to enter some directory path.
此路径何时起作用?
推荐答案
Eclipse在启动Java程序时使用此信息来构建 java.library.path
。
Eclipse uses this information to build the java.library.path
when it launches a Java program.
背景:某些Java框架依赖于本机代码。此代码通常以本机共享库(* .so,*。dll)的形式出现。在Java中,您可以看到属性为 native
的方法。该代码将使用 System.loadLibrary()
加载共享库。
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()
.
为了使代码独立于绝对路径,您只需将共享库的名称传递给 System.loadLibrary()
。然后,使用系统属性 java.library.path
确定VM应该在哪个目录中查找文件。
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.
结合Eclipse定义用户库的功能,您可以轻松地将依赖于本机代码的Java库添加到项目中。
Together with Eclipse's feature to define user libraries, you can easily add Java libraries that depend on native code to your projects.
这篇关于“本地库位置”是什么?入门在Eclipse中做?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!