
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/