How to find out what jar file provides a class during runtime using maven?

落花浮王杯 提交于 2019-12-01 11:36:25

try something like this:

    Class clazz = null;
    try {
        clazz = Class.forName( typeName );
        if ( clazz != null && clazz.getProtectionDomain() != null
                && clazz.getProtectionDomain().getCodeSource() != null )
        {
            URL codeLocation = clazz.getProtectionDomain().getCodeSource()
                    .getLocation();
            System.out.println( codeLocation.toString() );
        }
    }
    catch ( ClassNotFoundException e ) {
        System.out.println( e.getMessage() );
    }

where typeName="org.w3c.tidy.Tidy".

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!