Unsatisfiedlinkerror: No Opencv_Java249 in Java.Library.Path

java.lang.UnsatisfiedLinkError: no opencv_java2411 in java.library.path

-Djava.library.path shouldn't point to the DLL, but to the folder containing the DLL. e.g. -Djava.library.path=D:/Projects/lib/opencv/x86/

java.lang.UnsatisfiedLinkError: no opencv_java300 in java.library.path only while testing

In the end I solved it using absolute path in my tests like this:

@BeforeClass
public void setUp(){
System.loadLibrary("lib/x64/opencv_java300");
}

@Test
public void openCVTest(){
System.out.println("OpenCV configuration simple test:");
Mat m = Mat.eye(3,3, CvType.CV_8UC1);
System.out.println("OpenCV matrix = " + m.dump());
}

And in my application I am loading it normally:

 public class App {

static{ System.loadLibrary(Core.NATIVE_LIBRARY_NAME); }

public static void main( String[] args ){
System.out.println("OpenCV configuration simple test:");
Mat m = Mat.eye(3,3, CvType.CV_8UC1);
System.out.println("OpenCV matrix = " + m.dump());
}

}

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

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

UnsatisfiedLinkError while running on netbeans java project

Fixed it thanks to this tutoriel
http://www.codeproject.com/Tips/717283/How-to-use-OpenCV-with-Java-under-NetBeans-IDE

By changing VM options to add native library
"-Djava.library.path="C:\opencv\build\java\x86""

How do I resolve this UnsatisfiedLinkError?

First check java version.

java -version

After that install opencv

sudo apt install libopencv3.2-java
sudo ln -s /usr/lib/jni/libopencv_java320.so /usr/lib/libopencv_java.so


Related Topics



Leave a reply



Submit