Question:
How can I find out from where a class is loaded from?
Code:
public class ClassLocationTest { public static void main(String[] args) { ClassLocation cl = new ClassLocation(); System.out.println(cl.getClass().getProtectionDomain().getCodeSource().getLocation()); } } class ClassLocation { }
Output:
$ javac -d /tmp/classes ClassLocationTest.java $ java -cp /tmp/classes ClassLocationTest file:/tmp/classes/