クラスパス上にない場合、実行時にJavaライブラリ(.jarファイル)をロードする方法はありますか?
6337 次
1 に答える
6
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);
于 2010-11-06T06:01:39.133 に答える