NO opencv_java300 in java.library.path

Thanks in advance.

I have a project that uses opencv-300.jar as an external library. I tried this in eclipse and in natBeans. In both cases, it works successfully when I start my project from the IDE itself. I want my project to export it as an executable (or executable) jar. I placed the opencv_java300.dll file in the source folder with the main java file and gave my name in

System.loadLibrary("opencv_java300"); 

I placed opencv-300.jar in external jar libraries and all other files that are needed in the main program. It works successfully when working with the IDE, but when I create an executable jar, it shows an error

  Exception in thread "main" java.lang.UnsatisfiedLinkError: no opencv_java300 in java.library.path at java.lang.ClassLoader.loadLibrary(Unknown Source) at java.lang.Runtime.loadLibrary0(Unknown Source) at java.lang.System.loadLibrary(Unknown Source) at CropFaceImage.main(CropFaceImage.java:27) 

Please tell me which way to give java.library.path in the program itself. My project works without problems, even when I deleted the path for the opencv_java300.dll file in an external library.

+6
source share
5 answers

I tried passing the command containing the path for opencv , but I did not find another path. Somehow I tried something that created my jar, and it works fine. I copied the opencv_java300.dll file and placed it in the directory that is next to my jar file and did the same for all supporting files. For this, I used the following code.

 String opencvpath = System.getProperty("user.dir") + "\\files\\"; String libPath = System.getProperty("java.library.path"); System.load(opencvpath + Core.NATIVE_LIBRARY_NAME + ".dll"); 
+8
source

You can use the command line argument as shown below and call your class with the main

 java -Djava.library.path="Folder which contains your dll" .... 
+2
source

I had the same problem, it was solved by switching the JRE System library. It seems that the problem only occurs when using jre1.8.0_65. Everything worked fine for me with jre1.8.0_25, jre1.8.0.45 and jre1.8.0.66

+1
source

I solved my problem when I set up my own library in eclipse. You need to select the library link to your OS platform.

Take a look here: adding openCV to the java build path in eclipse .

0
source

I was able to fix the error by deleting my System.loadLibrary("opencv_java300"); From the code and adding the jar file to the class path in the build.xml file:

 <jar destfile="program.jar" basedir="build/classes"> <manifest> <attribute name="Main-Class" value="com.src.program"/> <attribute name="Class-path" value="opencv-300.jar"/> </manifest> </jar> 
0
source

All Articles