-> It is an exception. It is of type java.lang.Exception.
where as It is an error. It is of type java.lang.Error.
-> It occurs when an application tries to load a class at run time which is not updated in the classpath.
where as It occurs when java runtime system doesn’t find a class definition,which is present at compile time, but missing at run time.
-> It is thrown by the application itself. It is thrown by the methods like Class.forName(),
loadClass() and findSystemClass().
where as It is thrown by the Java Runtime System.
-> It occurs when classpath is not updated with required JAR files.
where as It occurs when required class definition is missing at runtime.
**** ClassNotFoundException ***
Ex.
public class MainClass
{
public static void main(String[] args)
{
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
}catch (ClassNotFoundException e)
{
e.printStackTrace();
}
}
}
******** NoClassDefFoundError *******
Ex....
class A
{
// some code
}
public class B
{
public static void main(String[] args)
{
A a = new A();
}
}
Comments
Post a Comment