First of all, I have a basic example of OpenCV running in a main method. However, if I use OpenCV in a Spring Web Controller, an error is thrown.
I am getting an Uns
It turns out that the default run configuration to start a Tomcat server within STS/Eclipse is essentially just a launcher for Tomcat. This means that any VM Args that are added to the Tomcat 'run configuration' will not be transferred to the actual Tomcat instance.
On looking in tcruntime-instance.bat
within the Tomcat directory (this is what ends up creating the tomcat java instance), we can see that simply by adding our intended VM Args to the JAVA_OPTS
environment variable, the dlls will be available to Tomcat.
TL;DR:
So.. Simply add the the locations of the OpenCV binaries to your JAVA_OPTS
environment variable:
-Djava.library.path="C:\opencv\build\java\x64;C:\opencv\build\x64\vc10\bin"
For more information on setting JAVA_OPTS for Tomcat, see this SO question.
Same thing here.
I try what Dylan said, but did not work here.
But I added "C:\opencv\build\java\x64;C:\opencv\build\x64\vc10\bin" on my PATH variable. On my sys variables.
ps: I'm using windows.