title: How to add an external library (OpenCV .jar file) to the Java build path from the command line (Unix)
body: <p>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 <strong>Documents/Programming/Ko/bin</strong> and the .jar file for the OpenCV library is located in <strong>Documents/Programming/opencv-2.4.10/build/bin</strong>. As suggested from a number of different questions on here, I have tried (while in the Ko/bin directory):  </p>
  
  <p><code>java -cp "/Users/jordan/Documents/Programming/opencv-2.4.10/build/bin/*:." Ko &lt;image_name&gt;</code>  </p>
  
  <p>Which produces the following error:  </p>
  
  <pre><code>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)  
  </code></pre>
  
  <p>So the program runs into an issue at line 37. This line is:  </p>
  
  <pre><code>System.loadLibrary(Core.NATIVE_LIBRARY_NAME);  
  </code></pre>
  
  <p>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:  </p>
  
  <pre><code>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)  
  </code></pre>
  
  <p>This time at line 39, which logically is the first time I call a method from the OpenCV library.  </p>
  
  <p>As far as I can tell, the way I'm writing the <code>java -cp ...</code> 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.</p>