Monday 4 July 2016

Java Tutorial : Java Exception handling (ClassNotFoundException vs NoClassDefFoundError)


Click here to watch in Youtube :
https://www.youtube.com/watch?v=LK9Ioh54kTM&list=UUhwKlOVR041tngjerWxVccw

Click the below Image to Enlarge
Java Tutorial : Java Exception handling (ClassNotFoundException vs NoClassDefFoundError) 
Java Tutorial : Java Exception handling (ClassNotFoundException vs NoClassDefFoundError) 
Java Tutorial : Java Exception handling (ClassNotFoundException vs NoClassDefFoundError) 
ClassNotFoundExceptionDemo.java
public class ClassNotFoundExceptionDemo
{

    public static void main(String[] args)
    {

        try
        {
            Class.forName("oracle.jdbc.driver.OracleDriver");
        }
        catch (ClassNotFoundException e)
        {
            e.printStackTrace();
        }

    }

}
Output
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at ClassNotFoundExceptionDemo.main(ClassNotFoundExceptionDemo.java:9)
B.java
class A
{
    
}

public class B
{

    public static void main(String[] args)
    {
        A a=new A();
    }

}
Output
Exception in thread "main" java.lang.NoClassDefFoundError: A
    at B.main(B.java:11)
Caused by: java.lang.ClassNotFoundException: A
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 1 more
Click the below link to download the code:
https://sites.google.com/site/javaee4321/java/ExceptionDemo_CNFE_NCDFE_App.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/ExceptionDemo_CNFE_NCDFE_App

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/4babce59a384cb4ab41f12b03cd7d11227a4b186/BasicJava/ExceptionDemo_CNFE_NCDFE_App/?at=master

See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • 3 comments: