Tuesday, May 17, 2005

Classloading fun

How to find where a class is loaded from:

myClass.getClass().getProtectionDomain().getCodeSource().getLocation()

This may not work with rt.jar loaded classes, it's worth checking if getCodeSource() returns null or not.

No comments: