Tuesday, March 31, 2009

Tip: How to find to which jar a class file belongs

It's a common problem in larger projects, where you are using a Class reference, but you don't know which of the 20 jars in your project is actually providing the implementation.

In my case, I needed to know which jar file was providing the Hex class.

System.out.println(Hex.class.getProtectionDomain().
getCodeSource().getLocation().toString());

It turns out that it's in axis2.jar :)