How To Install OpenCV 3.3+ with Java on Mac
If you installed OpenCV on Mac via brew, such as by using
brew install opencv
Then you may be getting an error when trying to use System.loadLibrary(Core.NATIVE_LIBRARY_NAME) that says something like:
UnsatisfiedLinkError: no opencv_java331 in java.library.path
The solution to this is to reinstall OpenCV with the proper Java libs. Try the following steps:
brew install ant
brew edit opencv
# change -DBUILD_opencv_java=OFF to ON
brew uninstall opencv # if you installed opencv before
brew install --build-from-source opencv # Note: this may take a long time
You may also need to point your IDE to the Java lib location by using a JVM arg such as:
-Djava.library.path=/usr/local/Cellar/opencv3/XXX/share/OpenCV/java
If you enjoyed this post, please check out my other blog posts.