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

viktors89 :

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: no opencv_java320 in java.library.path"

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.

Could you please help me?

Thanks!

SubOptimal :

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

assume following file structure

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

pom.xml - the part for the testing

<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");
    }    
}

run the test

mvn compile test

output

...
[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: ...
...

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=472322&siteId=1