Class Loading

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.


example result


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