1

My application has recently started throwing NoClassDefFoundError errors when I am running my application from within NetBeans. It never used to do this.

And when I run this outside of NetBeans using the command line argument that it provides once built, these errors are not produced

Is this a bug with Netbeans?

I have reinstalled NetBeans as I recently had another that was resolved by reinstalling, however the problem still persists.

Symbol error in java application using netbeans 6.8 when adding a shared project to library

Within Netbeans

alt text http://inverse.seednet.eu/snaps/ojtjal.png

Outside NetBeans alt text http://inverse.seednet.eu/snaps/gdwb5y.png

Community
  • 1
  • 1
Malachi
  • 33,142
  • 18
  • 63
  • 96

5 Answers5

1

The issue is the run time classpath of the run configuration when you are running it from netbeans. Make sure your run config has the jar containing these classes

Fazal
  • 2,991
  • 7
  • 29
  • 37
  • That fixed the issue! - It's odd how it randomly stopped working, and didn't pick up the libraries from the build path... hmm – Malachi Apr 23 '10 at 22:00
  • And now for some reason that has stopped working :/ even though the run time classpath has the jar files... proper odd http://inverse.seednet.eu/snaps/pptnac.png – Malachi Apr 23 '10 at 22:43
1

My solution consisted of setting the Main Class in Project Properties/Run. In that window click Browse to see all classes. In my case the main class was gone, to get it to reappear I added a syntax error to the main class, rebuilt, corrected the mistake, rebuilt, and then I was able to set the main class properly.

John
  • 1,671
  • 2
  • 13
  • 14
1

So I had this problem as well. I read Temp_user's solution above, and did something similar, though my main class was present in Project Properties/Run. My program consisted of four separate classes. After going through each, adding a syntax error, clean and build, correcting the syntax error and cleaning and building again, the program works. I don't really understand how this fixed anything. Any insight would be appreciated.

  • 1
    I had this exact problem and Temp__User's solution is what fixed it for me. Except there were 33 classes I had to do it for :-/ Pretty annoying bug... I experienced this in Netbeans 7.0 by the way. – Eternal Rubyist Dec 11 '12 at 23:18
0

I had the same problem, NoClassDefFoundError out of the blue. What seems to have caused the problem in my case was initializing a Handler in a static Context. Although i have done this succesfully before. this specific instance caused the following exception:

10:45:08.196    19376   com.certhon.activities  ERROR   QualiflexApp    Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()

Solving this also solved the NoClassDefFoundError, maybe the the handler causes app initialization to malfunction or something?

Im not very sure what went wrong or if this will help anyone, but, can't hurt to share right?

Midge
  • 51
  • 3
0

We had jar-library correctly added to Project Libraries and working fine. Then, suddenly, it stopped working with this error.

To solve:

 1. Delete build and dist folders in the Project.
 2. Remove and add the library back to Project - Libraries. 
 3. Rebuild Project.
Zon
  • 18,610
  • 7
  • 91
  • 99