java tutorial, Uncategorized

ClassNotFoundException vs NoClassDefFoundError in Java

http://onlywire.com/r/48857833 Before seeing the differences between ClassNotFoundException and NoClassDefFoundError let’s see some similarities which are main reason of confusion between these two errors:1) Both NoClassDefFoundError and ClassNotFoundException are related to unavaibility of a class at runtime.2) Both ClassNotFoundException and NoClassDefFoundError are related to java classpath.Now let’s see the difference between NoClassDefFoundError and ClassNotFoundException:1) ClassNotFoundException comes in java if we try to load a class at runtime using with Class.forName() or ClassLoader.loadClass() or ClassLoader.findSystemClass() method and requested class is not available in Java. the most of the time it looks like that we have the class in classpath but eventually it turns out to be issue related to classpath and application may not be using classpath what we think it was using e.g. classpath defined in jar’s manifest file will take precedence over CLASSPATH or -cp option, for more details see How classpat
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s