Tutorial :Why is this NoClassDefFoundError being thrown when the class exists?


I've tried to create a generic Observable class that I can use in my program:

public class GeoGolfObserver<T> extends Observable  {      public GeoGolfObserver()      {          super();      }        public void passObject(T object)      {          setChanged();          notifyObservers(object);      }  }  

It is created using:

GeoGolfObserver<Cache> cacheObserver = new GeoGolfObserver<Cache>(); // [1]  cacheObserver.addObserver(this);  new CreateCache(cacheObserver).setVisible(true);  

This is passed in to the constructor of the CreateCache class:

public CreateCache(GeoGolfObserver<Cache> cacheObserver) {      initComponents();      bindList();      this.cacheObserver = cacheObserver;  }  

However, the line marked [1] above throws an error:

  Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: Common/GeoGolfObserver



One of your classes is not found in the classpath. Specifically, GeoGolfObserver, if I understand your error correctly.

Check that you have valid references to all of your classes, and respective JAR/class files for them in your classpath.



The problem was fixed by simply telling netbeans to do a clean rebuild of my application. Thanks for your comments guys.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »