UnsatisfiedLinkError with OpenCV in Tomcat

前端 未结 2 1426
醉酒成梦
醉酒成梦 2021-01-15 14:49

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

相关标签:
2条回答
  • 2021-01-15 14:52

    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.

    0 讨论(0)
  • 2021-01-15 15:11

    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.

    0 讨论(0)
提交回复
热议问题