Saturday, July 4, 2009

Find a class has been loaded by which Jar

How to know from which jar file a class has been loaded?

public static String whichJAR(Class clazz){
String name = clazz.getName();
name = name.substring(name.lastIndexOf(’.') + 1);
String jar = clazz.getResource(name + “.class”).toString(); //NOI18N
return jar.substring(0, jar.indexOf(’!'));
}

Sphere: Related Content

0 comments: