EK.*_*EK. 4 java java-native-interface maven-2 netbeans native
我在我的java项目中使用maven,我不明白如何添加本地库。在我的非 Maven 项目中,我是通过 CLASSPATH 完成的。我在当前的 java 项目中使用 NetBeans 和 maven。
如果您只想将本机库添加到类路径中,请尝试将它们放入src/main/resources.
更新:您可以指定资源在 POM 中的位置:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<build>
...
<resources>
<resource>
<filtering>false</filtering>
<directory>${basedir}/src/main/native</directory>
<includes>
<include>native.so</include>
</includes>
</resource>
</resources>
<testResources>
...
</testResources>
...
</build>
</project>
Run Code Online (Sandbox Code Playgroud)
但老实说,如果你决定使用 Maven,你应该采用 Maven 的标准布局(或者你必须为你的自定义布局配置每个插件,这更多的是问题的根源而不是好处)。