Is there a way to load a java library (.jar file) at runtime, if 开发者_如何转开发it is not on the classpath?
URLClassLoader child = new URLClassLoader (myJar.toURL(), this.getClass().getClassLoader());
Class classToLoad = Class.forName ("com.MyClass", true, child);
Method method = classToLoad.getDeclaredMethod ("myMethod");
Object instance = classToLoad.newInstance ();
Object result = method.invoke (instance);
Source: How should I load Jars dynamically at runtime?
精彩评论