内部类的NoClassDefFoundError

时间:2014-08-28 13:48:19

标签: java swing noclassdeffounderror

因此,我发现这对于新的Java程序员来说是一个非常普遍的问题。然而今天是我第一次遇到它,经过八个月的Java编程。

这个程序在很长一段时间内都运行良好。我昨晚对Swing布局进行了一次小调整,最后有机会在今天早上出现错误时尝试一下。我做的调整可以未完成,但我相当肯定它与此错误无关。

错误告诉我它出现在以下行:

private CheckTreeTableSelectionListener selectionListener = new CheckTreeTableSelectionListener();

位于班级顶部的字段列表中。这是有趣的一点:CheckTreeTableSelectionListener 内部类 。它不是 外部也不是导入的。此外,我昨晚没有触及那个内部类,也没有触及创建它的新实例的字段。现在我理解(几乎没有)NoClassDefFoundError消息意味着可以在编译时找到类定义,但不能在运行时找到。这并没有真正帮助。如果它是一个内部类,怎么能找不到它?它就在那里,在实例化它的类中!

修改

根据要求,这是stacktrace:

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: info/chrismcgee/sky/Scheduling$CheckTreeTableSelectionListener
at info.chrismcgee.sky.Scheduling.<init>(Scheduling.java:165)
at info.chrismcgee.sky.Scheduling$2.run(Scheduling.java:204)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:744)
at java.awt.EventQueue.access$400(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:697)
at java.awt.EventQueue$3.run(EventQueue.java:691)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:714)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.ClassNotFoundException: info.chrismcgee.sky.Scheduling$CheckTreeTableSelectionListener
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 16 more

1 个答案:

答案 0 :(得分:6)

在Eclipse IDE中,有些课程会神奇地消失。你可以试试Project - &gt;清洁以重建所有。