gpt4 book ai didi

java - jar 文件未使用 stacktrace 执行另一个应用程序中的所有功能

转载 作者:行者123 更新时间:2023-12-01 07:58:04 25 4
gpt4 key购买 nike

我正在用 java 创建一个独立的应用程序。我通过 Netbeans IDE 创建该应用程序的 jar 文件; .jar 在我的系统中工作正常,但在另一个系统中无法工作所有功能。我在我的应用程序中使用 jar 库。异常显示 Noclassdeffound。此应用程序扫描二维码。这在我的系统中工作正常,但即使网络摄像头在另一个系统中也无法打开。请帮我。谢谢。

堆栈跟踪如下

C:\Users\Shubham\Downloads>java -jar JavaApplication1(2).jar
h3llo44444
hello world1111=null
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: com/githu
b/sarxos/webcam/WebcamPanel
at javaapplication1.MainFrame.jButton2ActionPerformed(MainFrame.java:248
)
at javaapplication1.MainFrame.access$100(MainFrame.java:33)
at javaapplication1.MainFrame$2.actionPerformed(MainFrame.java:104)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Sour
ce)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
ce)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
ce)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
ce)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.github.sarxos.webcam.WebcamPane
l
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
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)
... 39 more

最佳答案

当 Java 虚拟机 (JVM) 或 ClassLoader 类的实例尝试加载类的定义,但找不到该定义时,会引发 Noclassdeffound 错误。其中某个类依赖于其他类,并且该类不可访问。

简而言之,如果您使用了任何外部 jar 文件,则在编译时以及运行时都需要该 jar 文件,而且在您的情况下,JVM 似乎无法找到包含以下内容的外部 jar 文件:运行时的 WebcamPanel 类。因此您还需要将该 Jar 文件与应用程序的 Jar 文件一起打包。

如何在项目中添加External Jar文件可以引用 How can I include external jar on my Netbeans project

关于java - jar 文件未使用 stacktrace 执行另一个应用程序中的所有功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27597324/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com