Skip to main content

ClassNotFoundException vs NoClassDefFoundError

Both ClassNotFoundException and NoClassDefFoundError errors will be occurred  when the required Class not present in the Class path.
   
ClassNotFoundException
   
ClassNotFoundException is an Exception got arized when trying load class using
forName() method in class Class.
findSystemClass method in class ClassLoader .
loadClass method in class ClassLoader.

e.g. Class.forName("oracle.jdbc.driver.OracleDriver")
if the OracleDriver class file is not present in the Class path, then we will end up with this ClassNotFounException

NoClassDefFoundError

NoClassDefFoundError is an Error thrown at Runtime, when the Class is present during the compile time and not present during Runtime of the Code, then we will end up with this NoClassDefFoundError.

1. When required Class is not available at Runtime available only in compile time.
2.Since NoClassDefFoundError error is an Subclass of LinkageError, it will occur when one of the     Dependent of the jar not present in class path.
3. When the Static initialization of Class failed then it triggers java.lang.ExceptionInInitializerError
 which also leads to this Error.

e.g.  Exception in thread "main" java.lang.NoClassDefFoundError

Comments

Popular posts from this blog

Connection Time out Vs Socket Time out

Time out Any client(or source) which is unable to connect to the server (or Destination) in a specified time, then requests will automatically gets time outs. Port Port numbers allow different applications on the same computer to utilize network resources without interfering with each other. Port numbers most commonly appear in network programming, particularly socket programming. Sometimes, though, port numbers are made visible to the casual user. For example, some Web sites a person visits on the Internet use a URL like the following: http://www.appdomain.in:80/ In this example, the number 80 refers to the port number used by the Web browser to connect to the Web server. Normally, a Web site uses port number 80 and this number need not be included with the URL (although it can be). Port 80 is the default port for HTTP Socket Each and every communication from one application to another application should happen through sockets. Socket is gateway to send/receive information from one a...

"immutability" Nature of an Object

Immutability. A Java object is considered to be immutable when its state (properties and contents) cannot change after it is created. Use of immutable objects is widely accepted as a sound strategy for creating simple, reliable code. Immutable objects are particularly useful in concurrent applications. Since they cannot change state, they cannot be corrupted by thread interference or observed in an inconsistent state. java.lang.String and java.lang.Integer classes are the Examples of immutable Immutable objects are simple to use test and construct. Immutable objects are thread-safe by default. Immutable objects are good Map keys and Set elements (Since state of these objects must not change while stored in a collection). This is the reason most of the times we prefer String objects as Key in many Map Collection objects. Immutable objects do not require an implementation of clone. Immutable objects allow hashCode to use lazy initialization, and to cache its return value. To crea...

Self Signed Certificates Vs Signed Certificates (CA Certificates)

Certificates Certificates basically two categories. Self Signed Certificates  - will create by self CA Certificates  - will be  provided by Third party vendor with robust algorithms Depends on the location of installing the certificate these are two types 1. Public Key Certificates (Client Side) 2. Private Key Certificates (Server Side) Self Signed Certificates   If any one is using self signed certificates in their applications they have to make sure both server side and client side certificates are in sync. Other wise we should be ready to face SSLHandShake Exceptions. These will be preferable mostly for lower environments not for production. CA certificates  If you install CA certificates on server side, client side certificates are installed automatically whenever they access the server. So in production for CA certificates there is no need to install the client side certificates. We can generate a Self Signed Certificate using Java Key tool JAVA_HOME/bi...