ClassNotFoundException : This is checked exception and occurs when class is not found at runtime.The reason for this could be classpath is not updated with required jars.
// Java Program to Illustrate ClassNotFoundException
public class Demo {
// Main driver method
public static void main(String args[])
{
// Try block to check for exceptions
try {
Class.forName("ApachePOI");
}
// Catch block to handle exceptions
catch (ClassNotFoundException ex) {
// Displaying exceptions on console along with
// line number using printStackTrace() method
ex.printStackTrace();
}
}
}
NoClassDefFoundError: This is unchecked exception and occurs when class was present during compile time but absent during runtime. This generally happens when no .class file is present at runtime.This is kind of LinkageError.
No comments:
Post a Comment