by BehindJava

What is java.lang.ClassNotFoundException in Java and How to resolve it

Home » java » What is java.lang.ClassNotFoundException in Java and How to resolve it

In this blog, we are going to learn about what is ClassNotFoundException and its resolution.


  • This exception is thrown when an application tries to load any class at runtime using class.forName or loadClass() or findSystemClass() methods.
  • loadClass() and findSystemClass() methods are from the class loader class. So when the specified class is not found in the class path this exception is thrown.
  • This exception also occurs when you have two class loaders. If a class loader tries to access a class that is loaded by another class loader in Java.

Example: Lets say, we have a class where we specified the database jar name in the Class.forName. But intentionally we didn’t update the class path with the required JAR. In this case we get the ClassNotFoundException error as shown below.

public class BehindJava {

	public static void main(String[] args) {
		try {
		} catch (Exception e) {


java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(
	at java.base/java.lang.ClassLoader.loadClass(
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(
	at ds.BehindJava.main(