import java.security.ProtectionDomain;
import java.security.CodeSource;
public static void main(String[] args) {
ProtectionDomain pd = StringUtils.class.getProtectionDomain();
CodeSource cs = pd.getCodeSource();
System.out.println(cs.getLocation());//输出jar包路径
}
输出结果:file:/D:/workspace/springtest/WebContent/WEB-INF/lib/commons-lang-2.4.jar