简体   繁体   English

java.lang.NoClassDefFoundError-除了该类存在

[英]java.lang.NoClassDefFoundError - except the class exists

I'm using NetBeans IDE to code my Java program. 我正在使用NetBeans IDE编写Java程序。 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. 现在,我再次打开它以添加一些更改和注释,此java.lang.NoClassDefFoundError突然弹出。 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. 我已将CLASSPATH设置为Java文件夹(* C:\\ Program Files \\ Java \\ jdk1.6.0_26 \\ bin *),但仍然无法使用。 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 ). 在我的程序中,我有两个类WordDictionary )和一个JFrame表单( MainForm )。 Inside the Dictionary class, I have a function called testDictionary that inserts dummy data (ten Word objects) into the Dictionary object. Dictionary类内部,我有一个称为testDictionary的函数,该函数将伪数据(十个Word对象)插入Dictionary对象。 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. 并且出现java.lang.NoClassDefFoundError 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) 运行>清理并构建主项目(Shift + F11)

then I tested it again and it worked. 然后我再次对其进行了测试,并成功了。 Though I still don't know how to ACTUALLY solve the problem. 虽然我仍然不知道如何实际解决问题。

I have already fixed this by going to 我已经通过解决此问题

Run > Clean and Build Main Project (Shift + F11) 运行>清理并构建主项目(Shift + F11)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM