Please provide a good, thorough tutorial about Java class loading, focusing on how to extend that mechanism and how to actually work with the extension.
Class loaders are responsible for loading Java classes dynamically to the JVM (Java Virtual Machine) during runtime. They're also part of the JRE (Java Runtime Environment). Therefore, the JVM doesn't need to know about the underlying files or file systems in order to run Java programs thanks to class loaders.
The Java ClassLoader is a part of the Java Runtime Environment that dynamically loads Java classes into the Java Virtual Machine. The Java run time system does not need to know about files and file systems because of classloaders.
Each application might use different versions of the same libraries, and must thus have a different classloader from the others in order to be able to have different versions of the same classes in a single JVM. but the web server has its own loader.it can have several classloaders.
We will create our own ClassLoader by extending the ClassLoader class and overriding the loadClass(String name) method. If the class name will start from com. journaldev then we will load it using our custom class loader or else we will invoke the parent ClassLoader loadClass() method to load the class.
There's obviously Sun's trail which gives you the technical foundations. I find that despite being thirteen years old(!) this JavaWorld article is still a very good place to start - the technicalities of classloading haven't changed much or at all since then, to my knowledge. (Someone please correct this if there have been any important changes since then!).
IBM are usually good for technical Java articles, and they don't disappoint here. O'Reilly also have a more recent article that covers much the same thing but has a pretty diagram in it. :-)
The Mindprod Java Glossary has a good description of what a classloader is and lists tutorials and technical articals at the end of the page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With