8

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.

Darkhydro
  • 1,992
  • 4
  • 24
  • 43
  • 1
    Can you see the class `UpdateNameForm` if you search for it in NetBeans? – Buhake Sindi Jun 03 '11 at 06:44
  • @The Elite yes I can. It is in the project, and in the classes folder of the netbeans project itself. Check the update above please – Darkhydro Jun 03 '11 at 06:54
  • do you have a build script that cleans your build? – Buhake Sindi Jun 03 '11 at 07:07
  • @The Elite like i said, it is a netbeans project. The clean and build button in netbeans does this automatically. It also rebuilds the programs final JAR file into the "dist" folder, and this JAR works. – Darkhydro Jun 03 '11 at 07:09
  • I'm experiencing the same thing with one of my projects in NB7... worked fine a few days ago. In my case it's a web app and it fails when loading beans from the spring application context. – pilotcam Oct 11 '11 at 19:11
  • Yes! This is second time this has happened. – Lucas Nov 08 '12 at 22:52

5 Answers5

3

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.

Nik
  • 695
  • 1
  • 4
  • 15
  • I don't understand what you mean. I have no JAR's in my build path. The only JAR necessary to build my project is AbsoluteLayout.JAR – Darkhydro Jun 03 '11 at 06:51
1

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.

Odd Steen
  • 11
  • 1
  • This answer assisted in resolving my issue with NetBeans 10. Simply adding a system.out & saving the file, then remove it afterwards.I didn't need to perform any additional steps. – ManxDev Jun 12 '19 at 16:25
0

These kinds of problems are almost always due to classpath issues.

  • Check your classpath setting
  • Check that the jar containing your class can be found in the execution environment
  • Check that the class isn't in another jar found earlier in your classpath - especially an earlier/later version of the jar (ie if you've upgraded but not cleared out your old jars)
Bohemian
  • 412,405
  • 93
  • 575
  • 722
  • I don't know how to check my classpath. All of my classes are stored in the build folder of the netbeans project, and they are all there. The only JAR necessary to building is AbsoluteLayout.JAR – Darkhydro Jun 03 '11 at 06:51
  • This is the only answer with an aproach to actually solving this error – Ordiel Jun 10 '20 at 14:10
  • Responding with a link to a site selling software for $8,995 is hardly what I would call helpful. – Shanemeister Jun 28 '21 at 16:37
  • @Shanemeister it’s not software for sale, it’s the domain for sale because the site has shut down and they let the domain ownership expire. I’ve removed the link. – Bohemian Jun 28 '21 at 17:54
0

I have solved my problem by creating a new netbeans project from the existing sources. In my opinion, this is not a good way to do things (especially on large projects) but none of the existing answers provided a solution.

Darkhydro
  • 1,992
  • 4
  • 24
  • 43
0

Try remove the .cache folder, it worked for me. For example in my machine, cache folder of netbeans is located at /home/chieuvh/.cache/netbeans/15

chieuvh
  • 21
  • 3