Maven项目无法调用jar文件 [英] Maven project fail to call jar file

查看:222
本文介绍了Maven项目无法调用jar文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在maven项目中使用 OpenCV 代码, opencv-310.jar 已创建并运行良好。

I want to use OpenCV code in maven project, the opencv-310.jar created and run well.

关于这个页面调用本地jar文件的方式,我安装jar

following this page the way call local jar file, I install the jar

mvn install:install-file 
-Dfile=/home/administrator/NetBeansProjects/OpenCV_Maven/opencv-310.jar 
-DgroupId=localLibrary 
-DartifactId=OpenCV -Dversion=3.1.0 -Dpackaging=jar 
-DgeneratePom=true

并将 POM as低于代码

<dependencies>
    <dependency>
        <groupId>localLibrary</groupId>
        <artifactId>OpenCV</artifactId>
        <version>3.1.0</version>
    </dependency>
</dependencies>    

然后运行面部检测应用程序示例代码。如下所示,例外情况发生在调用 Core.NATIVE_LIBRARY_NAME 的行中,似乎找不到jar。

Then run the Face detection application sample code. The exception, like below, occurred at the line calling Core.NATIVE_LIBRARY_NAME, seems it failed to found jar.

Exception in thread "main" java.lang.UnsatisfiedLinkError: no opencv_java310 in java.library.path

我无法弄清楚如何修复,当我用destop应用程序练习库时出现了同样的问题,但无法以相同的方式解决它。(添加VM选项 -Djava.library.path

I can't figure out how to fix, the same problem appeared when I practice the library with destop application, but can't solve it in same way.(add VM option-Djava.library.path)

顺便说一句,我不使用 libopencv_java310.so 同时使用 opencv-310.jar 创建。我不确定是否有必要,如果必须添加到maven项目,请告诉我如何使用它,我从未使用过这种文件。

By the way, I don't use libopencv_java310.so that was created with opencv-310.jar at the same time. I am not sure is it necessary or not, if it have to be add to maven project, please tell me how to use it, I never used this kind of file.

感谢您的帮助。

推荐答案

正如@Tome所说,本地图书馆遗漏的问题原因。

As @Tome said, the problem cause by native library missed.

所以我喜欢,

public static void main(String[] args) {
System.out.println("Hello, OpenCV");

// Load the native library.
//System.loadLibrary(Core.NATIVE_LIBRARY_NAME); instead by below code
String path = "/home/administrator/OpenCV_jar/libopencv_java310.so";
System.load(path);
new DetectFaceDemo().run();
}

这篇关于Maven项目无法调用jar文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆