java.lang.NoClassDefFoundError - 类存在除外
我正在使用 NetBeans IDE 来编写 Java 程序。几天前,我让它按照我想要的方式工作。现在我再次打开它添加一些更改和注释,突然弹出这个java.lang.NoClassDefFoundError。我四处搜寻,但似乎找不到正确的答案。我已将 CLASSPATH 设置为 Java 文件夹 (*C:\Program Files\Java\jdk1.6.0_26\bin*),但它仍然无法工作。我正在考虑将所有代码复制并粘贴到不同的目录中,但我担心将来仍然会出现问题,并且一旦程序变得非常大,更改项目的位置会很麻烦。
在我的程序中,我有两个类(Word 和Dictionary)和一个 JFrame 表单(MainForm)。在 Dictionary 类中,我有一个名为 testDictionary 的函数,它将虚拟数据(十个 Word 对象)插入到 Dictionary 中> 对象。这是几天前运行的,没有任何错误,但是当我今天运行该程序时,它停在显示以下内容的行上:
Word myWord = new Word();
并出现 java.lang.NoClassDefFoundError 。请帮我解决这个问题,以防将来再次出现。非常感谢。 :)
编辑: 我已经通过转到
运行 > 解决了这个问题清理并构建主项目(Shift + F11)
然后我再次测试它并且它有效。虽然我仍然不知道如何真正解决这个问题。
I'm using NetBeans IDE to code my Java program. A few days ago, I had it working the way I wanted to. Now that I opened it again to add some changes and comments, this java.lang.NoClassDefFoundError popped up suddenly. I have searched around but I can't seem to find a proper answer. I have set my CLASSPATH to my Java folder (*C:\Program Files\Java\jdk1.6.0_26\bin*) but it still won't work. I'm thinking of copying and pasting all my codes in a different directory but I'm afraid that the problem would still happen in the future, and changing the project's location would be too much of a hassle once the program gets really big.
In my program, I have two classes (Word and Dictionary) and a JFrame form (MainForm). Inside the Dictionary class, I have a function called testDictionary that inserts dummy data (ten Word objects) into the Dictionary object. This was running a few days ago, with no error whatsoever, but when I ran the program today, it stops on the line that says:
Word myWord = new Word();
and the java.lang.NoClassDefFoundError appears. Please help me resolve this issue, in case it appears in the future again. Thank you very much. :)
EDIT:
I have already fixed this by going to
Run > Clean and Build Main Project (Shift + F11)
then I tested it again and it worked. Though I still don't know how to ACTUALLY solve the problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经通过转到
运行 > 解决了这个问题清理并构建主项目(Shift + F11)
I have already fixed this by going to
Run > Clean and Build Main Project (Shift + F11)