• Post Reply Bookmark Topic Watch Topic
  • New Topic

java.lang.NoClassDefFoundError (but the class is there)  RSS feed

 
Lance Gray
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been writing this project of mine in Java for quite some time now. I've repeatedly built and tested my project (I use NetBeans 6.8on Windows 7, by the way) several times before. Then I went and edited something in the project. Then when I tried to run it from there, this java.lang.NoClassDefFoundError popped up all of a sudden. I've looked into the internet and searched how to fix it but nothing seems to work. I've set my CLASSPATH on the Environment Variables but it won't get fixed. How do I fix this?

It's annoying the heck out of me now since I need to pass this project tomorrow and I was sure everything was working fine. Thanks in advance and I hope someone will answer this quickly.
 
J. Kevin Robbins
Bartender
Posts: 1801
28
Chrome Eclipse IDE Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remove the classpath environment variable and forget about using it. Doing so will only cause you grief.

Right click the Netbeans project and choose properties. Click the Libraries category and make sure all the required jar files are listed in the compile-time libraries list. If you aren't sure which jar file you need, check your stack trace to determine which class threw the error and then you may have to do a google search to determine what jar file contains that class.
 
Lance Gray
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jk Robbins wrote:Remove the classpath environment variable and forget about using it. Doing so will only cause you grief.

Right click the Netbeans project and choose properties. Click the Libraries category and make sure all the required jar files are listed in the compile-time libraries list. If you aren't sure which jar file you need, check your stack trace to determine which class threw the error and then you may have to do a google search to determine what jar file contains that class.

For some reason, removing the CLASSPATH variable did the trick. I didn't imported any new JAR files in the Library. I think it's weird. Before I did the changes, everything worked fine, but after the change it threw this error, even though the Library and CLASSPATH the same for both times. How come? Also, how do I determine which class threw the error on the stack trace? Is it the class listed on the end? Oh, and thanks a bunch.
 
Campbell Ritchie
Marshal
Posts: 56533
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The classpath evnironment variable is used by the JVM to find classes required for this particular application. If you set a system classpath, that will mislead the JVM into looking in the wrong place. A lot of books tell you to set a classpath, but that is usually mistaken advice.
 
J. Kevin Robbins
Bartender
Posts: 1801
28
Chrome Eclipse IDE Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Glad to hear that you're back on track. If you'll post the stack trace you got, one of us will show you how to analyze it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!