java动态添加类库

try {
	Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
	method.setAccessible(true);
	method.invoke(TestRun.class.getClassLoader(), new File("testclass").toURI().toURL());
	Class.forName("TestClass");
	System.out.println("find Class");
} catch (Exception e) {
	System.err.println("not find class");
}

 

你可能感兴趣的:(JAVA,特殊知识,类加载器,java)