Class Loading
Dangers%2520of2520overloading%2520your%2520horse%2520!_WEB.jpg

How to get the class loader of your class and its parent class loader

System.out.println("this class loader : "+ this.getClass().getClassLoader());
System.out.println("parent class loader : "+ this.getClass().getClassLoader().getParent());

example result

this class loader : sun.misc.Launcher$AppClassLoader@fabe9
parent class loader : sun.misc.Launcher$ExtClassLoader@df6ccd

How to find out where your class is loaded from

If you have ever had that feeling that your not sure your code is running the correct class file, then you can log this out, to show you where you class got loaded from.

System.out.println(this.getClass().getProtectionDomain().getCodeSource().getLocation());

example result
file:/C:/project/

how-to-find-calling-methods.html

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License