- NoClassDefFoundException is thrown if a class is referenced with Java’s “new” operator (i.e. static loading) but the runtime system cannot find the referenced class.
Ex: Employee e = new Employee();
- ClassNotFoundException is thrown when an application tries to load in a class through its string name using the following methods but no definition for the class with the specified name could be found:
- The forName(..) method in class - Class.
- The findSystemClass(..) method in class - ClassLoader.
- The loadClass(..) method in class - ClassLoader
Ex: Class employeeClass = Class.forName("com.samples.Employee") ;