简体   繁体   中英

Can't figure out how to set java.library.path

I've looked at several other similar questions here, but none of them have been helping. I am able to run my program in eclipse, but once I try to export it as a jar, it can't find the opencv library:

C:\Users\Cory\Desktop>java -jar MazeBot.jar
Exception in thread "main" java.lang.UnsatisfiedLinkError: no opencv_java249 in
java.library.path
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.loadLibrary0(Unknown Source)
    at java.lang.System.loadLibrary(Unknown Source)
    at MazeBot.main(MazeBot.java:38)

By looking at the responses for other questions, I tried setting my PATH variable to C:\\OpenCV (I put a copy of opencv_java249.dll in there), which didn't work at all. Then, I tried adding System.setProperty("java.library.path", "C:\\\\OpenCV") as the first line of my code, but this also did nothing.

I'm not sure what I'm doing wrong...

Try using: java -jar MazeBot.jar -Ljava.library.path="C:\\\\OpenCV"

This has cannot be in the application itself because you are importing OpenCV before the System.setProperty(...) line gets executed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM