"Java.lang.UnsatisfiedLinkError:java.library.path中没有opencv_java320" [英] "Java.lang.UnsatisfiedLinkError: no opencv_java320 in java.library.path"

查看:1356
本文介绍了"Java.lang.UnsatisfiedLinkError:java.library.path中没有opencv_java320"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我进行了硒测试,测试完成后可以使用OpenCV进行一些操作.使用IntelliJ IDEA,它可以正常工作,并且可以正确执行操作,但是当我尝试通过命令行执行(供Jenkins在不久的将来使用)时,出现上述错误:

I have a selenium test that when it finishes makes some operations with OpenCV. With IntelliJ IDEA it works fine, the operations process correctly, but when I try to execute through command line (for Jenkins use in the near future), I get the error mentioned above:

"Java.lang.UnsatisfiedLinkError:java.library.path中没有opencv_java320"

"Java.lang.UnsatisfiedLinkError: no opencv_java320 in java.library.path"

我在这里阅读了其他问题,并已将java.library.path设置为jar和dll文件所在的路径,但是错误仍然出现,并且我的想法不多了.

I read the other questions on here and I've set up the java.library.path to the path where the jar and dll files are, but the error still comes up and I'm running out of ideas.

能请你帮我吗?

谢谢!

推荐答案

请在下面找到有效的代码段.您需要根据自己的需要进行调整.

Please find below a working snippet. Which you need to adapt to your needs.

假设以下文件结构

libs\opencv_java320.dll
pom.xml
src\test\java\sub\optimal\OpenCVTest.java

pom.xml -测试部分

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.20</version>
            <configuration>
                <argLine>-Djava.library.path=${project.basedir}/libs/</argLine>
            </configuration>
        </plugin>
    </plugins>
</build>

sub \ optimal \ OpenCVTest.java

package sub.optimal;
import org.junit.Test;
public class OpenCVTest {
    @Test
    public void someOpenCVTest() {
        System.out.printf("java.library.path: %s%n",
                System.getProperty("java.library.path"));
        System.loadLibrary("opencv_java320");
    }    
}

运行测试

mvn compile test

输出

...
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running sub.optimal.OpenCVTest
java.library.path: X:\develop\opencv-demo/libs/
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: ...
...

这篇关于"Java.lang.UnsatisfiedLinkError:java.library.path中没有opencv_java320"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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