答:
引入tools.jar
package com.sun.tools.jdeps;
import org.junit.Test;
import java.io.IOException;
public class DependencyVisitorTest {
@Test
public void testDependencyWithJdeps() throws IOException {
JdepsTask task = new JdepsTask();
task.run(new String[] {"-v", "/home/zzl/Develop/WorkSpace/HUE100/forneus-preheat/forneus-preheat-lambda-skeleton/target/test-classes/com/sun/tools/jdeps/MyClass.class"});
}
}
执行结果
MyClass.class -> not found
MyClass.class -> /home/zzl/Develop/Application/oracle-jdk-1.8.0_151/jre/lib/rt.jar
com.sun.tools.jdeps.MyClass -> com.google.gson.Gson not found
com.sun.tools.jdeps.MyClass -> com.worksap.company.framework.forneus.ForneusViewId not found
com.sun.tools.jdeps.MyClass -> java.lang.Object
com.sun.tools.jdeps.MyClass -> java.lang.String
Process finished with exit code 0