本文介绍了为什么我得到NoClassDefFoundError:java / awt / Desktop?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我试图用Swing打开一个 URI ,我收到了上面的错误。



什么是原因和如何解决它?



当我在控制台中执行一切都可以,但是当我在GUI中,我得到这个错误。
我应该说我使用Weblogic作为服务器。



代码

  private static void open(URI uri){
if(Desktop.isDesktopSupported()){
try {
Desktop.getDesktop()。browse (URI);
} catch(IOException e){/ * TODO:错误处理* /}
} else {/ * TODO:错误处理* /}
}

堆栈跟踪

 线程中的异常AWT-EventQueue-1java.lang.NoClassDefFoundError:java / awt / Desktop 
at be.azvub.ext.bcfidownloder.BcfiDownloadPanel.open(BcfiDownloadPanel.java:230)
at be.azvub.ext.bcfidownloder.BcfiDownloadPanel.access $ 000(BcfiDownloadPanel.java:37)
at be.azvub.ext.bcfidownloder.BcfiDownloadPanel $ 7.actionPerformed(BcfiDownloadPanel.java:147)
在javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
在javax.swing.AbstractButton $ Handler.actionPerformed(AbstractButton.java:2169)
在javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel .java:420)
在javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
在javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java: 236)
在java.awt.Component.processMouseEvent(Component.java:5517)
在javax.swing.JComponent.processMouseEvent(JComponent.java:3129)
在java.awt.Component .processEvent(Component.java:5282)
在java.awt.Container.processEvent(Container.java:1966)
在java.awt.Component.dispatchEventImpl(Component.java:3984)
java.awt.Container.dispatchEventImpl(Container.java:2024)
在java.awt.Component.dispatchEvent(Component.java:3819)
在java.awt.LightweightDispatcher.retargetMouseEvent(Container。 java:4212)
在java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
在java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
在java.awt .Container.dispatchEventImpl(Container.java:2010)
在java.awt.Window.dispatchEventImpl(Window.java:1791)

$ b

NoClassDefFoundError.htmlrel =nofollow> NoCl assDefFoundError



当编译当前执行的类时,搜索到的类定义存在,但不能再找到定义。



你确实有一些不正确的类加载发生。主要是由于类加载器链接错误。


I'm trying to open an URI with Swing that I get above error.

What is the reason and how can I fix it?

When I do it in console everything is OK but when I do in GUI I get this error.I should say that I use Weblogic as server.

Code

private static void open(URI uri) {
    if (Desktop.isDesktopSupported()) {
        try {
            Desktop.getDesktop().browse(uri);
        } catch (IOException e) { /* TODO: error handling */ }
    } else { /* TODO: error handling */ }
}

Stack trace:

Exception in thread "AWT-EventQueue-1" java.lang.NoClassDefFoundError: java/awt/Desktop
at be.azvub.ext.bcfidownloder.BcfiDownloadPanel.open(BcfiDownloadPanel.java:230)
at be.azvub.ext.bcfidownloder.BcfiDownloadPanel.access$000(BcfiDownloadPanel.java:37)
at be.azvub.ext.bcfidownloder.BcfiDownloadPanel$7.actionPerformed(BcfiDownloadPanel.java:147)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:5517)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3129)
at java.awt.Component.processEvent(Component.java:5282)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3984)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3819)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
at java.awt.Container.dispatchEventImpl(Container.java:2010)
at java.awt.Window.dispatchEventImpl(Window.java:1791)
解决方案

Doc on NoClassDefFoundError

The searched-for class definition existed when the currently executing class was compiled, but the definition can no longer be found.

You do have some incorrect classloading happening. Mostly due to wrong class loader chaining.

这篇关于为什么我得到NoClassDefFoundError:java / awt / Desktop?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 15:55