Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NoClassDefFoundError but class exists

Here is the error:


Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: sfclocator/UpdateNameForm
    at sfclocator.SFCViewer.(SFCViewer.java:68)
    at sfclocator.SFCViewer$10.run(SFCViewer.java:1823)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Caused by: java.lang.ClassNotFoundException: sfclocator.UpdateNameForm
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)

I created this program as a Netbeans 7.0 project. I've been working on it for about 2-3 days, and finished it yesterday. It worked perfectly yesterday. I went to sleep, woke up, ran it this morning, and all of a sudden I got errors. I fixed the errors that popped up, except for this one.

The project builds perfectly, and the JAR even runs just fine, but when I try to run the project using Netbeans it gives me this error. Any help would be appreciated.


Further information i just found out:

When built, the UpdateNameForm class exists in the classes folder of netbeans project, but when i click run, it deletes the UpdateNameForm classes.

like image 372
Darkhydro Avatar asked Jun 03 '11 06:06

Darkhydro


2 Answers

i had a similar problem, i resolved it by first removing the jar from the build path and then adding it again. Build the project after re-adding the jar. Sometimes the build path is not refreshed... i hope this works for u too.

like image 127
Nik Avatar answered Sep 22 '22 18:09

Nik


I suddenly had the same problem. I checked the output of the build process in /build/classes and couldn't find the missing class. No wonder about the error message... My way to fix this in NetBeans 8.2 was to right-click on the project to open the Properties page. Then go to Compiling under Build and uncheck the Compile on Save box. After that I did some dummy editing of the problematic class - entering a System.out... and deleting it again - and save. After that I could right-click on the class and chose Compile File. Again checking in /build/classes I could see that the classes were now built. Running the program worked and I could re-check the Compile on Save box in the project Properties.

like image 24
Odd Steen Avatar answered Sep 21 '22 18:09

Odd Steen