1) ClassNotFoundException:When we try to load a class at run-time using with Class.forName() or ClassLoader.loadClass()or ClassLoader.findSystemClass()method and requested class is not available.
ClassNotFoundException occurs when class loader could not find the required class in class path. So, basically we should check our class path and add the class in the classpath.
NoClassDefFoundError: When a class is present during compile time but at run time the classes are changed or removed or class's static initializes threw exceptions.
2) ClassNotFoundException is a checked Exception derived from java.lang.Exception class and we can handle it while NoClassDefFoundError is an Error derived from LinkageError.
No comments:
Post a Comment