如何使用外部库在ide外运行jar



我得到了一个使用openv库的程序,该库在netbeans上运行良好,但当我尝试使用此命令在netbeans之外运行它时:

java -jar RecupPhotoV1
pause

i got this error:

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只是通过启动一个。bat或脚本在同一文件夹比我的jar

-----------------------------------------------------------------------------

编辑:昨天我尝试了一些事情,我从netbeans导出了我的项目到eclipse,跟着一个新的教程,新的清单等,我认为,事情正在好转。现在如果我执行:

java -jar RecupPhoto.jar

与此清单:

Manifest-Version: 1.0
Main-class: RecupPhoto
Class-path: opencv-300.jar

i got a thread error,

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

不知道是什么原因引起的?

opencv jar必须在类路径中。您必须运行如下命令:

java -classpath/path/to/lib -jar RecupPhotoV1

相关内容

  • 没有找到相关文章

最新更新