ProLesson 10.3Advanced3 min readUpdated 30 October 2026
Class loading
How the JVM finds and prepares classes, the three built-in class loaders, parent delegation, and when static initialisation happens.
The JVM doesn't load all your classes at start-up. It loads each class the first time it's needed. Understanding how explains ClassNotFoundException, NoClassDefFoundError, and when static blocks run.
01The three phases
- Loading: find the
.classbytes (in a folder, a JAR or a module) and create aClassobject. - Linking:
- verify that the bytecode is valid and safe,
- prepare memory for static fields with default values (
0,null), - resolve symbolic references to other classes (often lazily).
- Initialisation: run static initialisers and
static { }blocks, in source order. This happens once, on first active use.
Loading the rest of the lesson…