I am trying to add the OpenCV library to the build path for my Java program from the terminal so that I can use a shell script to run the program on a bunch of image files sequentially. The .class files for my project are located in Documents/Programming/Ko/bin and the .jar file for the OpenCV library is located in Documents/Programming/opencv-2.4.10/build/bin. As suggested from a number of different questions on here, I have tried (while in the Ko/bin directory):
java -cp "/Users/jordan/Documents/Programming/opencv-2.4.10/build/bin/*:." Ko <image_name>
Which produces the following error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no opencv_java2410 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1119)
at Ko.main(Ko.java:37)
So the program runs into an issue at line 37. This line is:
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
I added this line after running into issues loading the OpenCV library in Eclipse, from the advice of another question on here, although I'm not exactly sure what it does or why it is necessary. When I try commenting out this line I get a similar error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: org.opencv.highgui.Highgui.imread_0(Ljava/lang/String;I)J
at org.opencv.highgui.Highgui.imread_0(Native Method)
at org.opencv.highgui.Highgui.imread(Highgui.java:309)
at Ko.main(Ko.java:39)
This time at line 39, which logically is the first time I call a method from the OpenCV library.
As far as I can tell, the way I'm writing the java -cp ... command is identical to what has worked for others from the questions I've read on here. If anyone could tell me where I'm going wrong and could explain why the call to System.loadLibrary() is necessary in this particular case when in other cases of importing libraries it is not, it would be greatly appreciated.