Tuesday, 7 May 2019

Internals of JVM

How class loader works internally




String class will load from the bootstrap classpath because it is available in rt.jar

MyClass will be there in ext as well as in application path so preference goes to ExtentionClassPath

If and only if the class is not available in extension and available in Application classpath it will get loaded from the Application classpath

If all the above steps failed to load the class then JVM will throw ClassNotFoundException


ClassNotFoundException is an exception that occurs when you try to load a class at run time using Class.forName() or loadClass() methods and mentioned classes are not found in the classpath.

NoClassDefFoundError is an error that occurs when a particular class is present at compile time but was missing at run time. (ex. If you delete it after created in as a composite class  )