I'm trying to add opencv to my Spring Boot/Maven project.
In order to use opencv library I have to provide native lib into java.library.path.
I have added following command into Eclipse VM arguments:
-Djava.library.path="D:/Projects/lib/opencv/x86/opencv_java2411.dll"
and got a following exception:
java.lang.UnsatisfiedLinkError: no opencv_java2411 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
I'm also trying to access java.library.path
directly from my code:
System.out.println(System.getProperty("java.library.path"));
and it shows provided path: D:/Projects/lib/opencv/x86/opencv_java2411.dll
What am I doing wrong ?
I also face the same issue doing so i did below to solve the issue.When i ran ran java -jar openCV=project jar I got the same exception as below
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.UnsatisfiedLinkError: no opencv_java320 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at com.wso2telco.rnd.CamCapture.<init>(CamCapture.java:47)
at com.wso2telco.rnd.CamCapture.main(CamCapture.java:144)
... 5 more
so i did the below changes the project in the .java class i had this lines
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
System.loadLibrary("opencv_java320");
I removed those 2 lines and added the below line
nu.pattern.OpenCV.loadLocally();
in order add that line you need to have theses dependencies in pom.xml
<dependency>
<groupId>org.openpnp</groupId>
<artifactId>opencv</artifactId>
<version>3.2.0-0</version>
</dependency>
<dependency>
<groupId>nu.pattern</groupId>
<artifactId>opencv</artifactId>
<version>2.4.9-4</version>
</dependency>
After doing the above modification i was able to run my program from terminal using mvn exec:java -Dexec.mainClass="com.rnd.CamCapture"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With