我有一个程序,它使用在netbeans上运行良好的opencv库,但是当我尝试使用此命令在netbeans之外运行它时:
java -jar RecupPhotoV1
pause
我收到了这个错误:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no opencv_java300 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 recupphoto.Ihm.<init>(Ihm.java:96)
at recupphoto.RecupPhoto.main(RecupPhoto.java:18)
我把项目构建到文件夹dist中,jar在这里,opencv_300.jar在lib文件夹中。 我的目标是让这个应用程序在其他计算机上运行,而不是netbeans只是通过在与我的jar相同的文件夹中运行.bat或脚本
编辑: 昨天尝试了一些事情,我将我的项目从netbeans导出到eclipse,然后是一个带有新清单等的新教程,我想,情况会好转。现在,如果我执行:
java -jar RecupPhoto.jar
有了这个清单:
Manifest-Version: 1.0
Main-class: RecupPhoto
Class-path: opencv-300.jar
我遇到线程错误,
Exception in thread "main" java.lang.NoClassDefFoundError: org/opencv/videoio/VideoCapture
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getDeclaredMethod(Unknown Source)
at java.awt.Component.isCoalesceEventsOverriden(Unknown Source)
at java.awt.Component.access$500(Unknown Source)
at java.awt.Component$3.run(Unknown Source)
at java.awt.Component$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Component.checkCoalescing(Unknown Source)
at java.awt.Component.<init>(Unknown Source)
at java.awt.Container.<init>(Unknown Source)
at java.awt.Window.<init>(Unknown Source)
at java.awt.Frame.<init>(Unknown Source)
at java.awt.Frame.<init>(Unknown Source)
at javax.swing.JFrame.<init>(Unknown Source)
at Ihm.<init>(Ihm.java:82)
at RecupPhoto.main(RecupPhoto.java:10)
Caused by: java.lang.ClassNotFoundException: org.opencv.videoio.VideoCapture
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 17 more
Duno可能是什么原因?
答案 0 :(得分:0)
opencv jar必须在classpath中。你必须运行类似的东西:
java -classpath / path / to / lib -jar RecupPhotoV1