A NoClassDefFoundException is thrown during runtime if an object of a class created with the new() operator (static loading) cannot be found during runtime. This can happen due to many reasons:
1) You created a public class but did not save it with the right name. You will be able to compile it but not run it.
2) You did not include the class/jar in the classpath.
A ClassNotFoundExceptionis a checked exception thrown at runtime when you try to load a class using Class.forName() method. The String arguments to that method should contain a fully qualified class name and the class should be valid and included in the classpath. The best example is during a JDBC connectivity. To connect using JDBC you load the class at runtime using Class.forName(“com.mysql.jdbc.driver”). But if the MySQL connectivity mysql-connector-java.jar (which contains the driver class) cannot be found in the classpath then ClassNotFoundException will be thrown.