NoClassDefFoundError but class exists

Darkhydro picture Darkhydro · Jun 3, 2011 · Viewed 18.1k times · Source

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.

Answer

Nik picture Nik · Jun 3, 2011

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.