I have a simple question about the java classloading mechanism.
I think that the default class loader loads user-defined classes. If I specify other jars in the classpath, does the default classloader go through each jar and load classes from each jar at application startup?
No, it loads classes whenever they are first referenced, either through
Class.forName()or through direct use in your code.Example:
If you run
Firstas a main class, the output is: