プラグイン形式で機能拡張する場合は必須と思われる.
void addClassPath(File classPath){
try{
URLClassLoader classLoader=(URLClassLoader)ClassLoader.getSystemClassLoader();
try{
URLClassLoader classLoader=(URLClassLoader)ClassLoader.getSystemClassLoader();
Class classClassLoader = URLClassLoader.class;
Method methodAddUrl =
classClassLoader. getDeclaredMethod("addURL", URL.class);
methodAddUrl.setAccessible( true);
methodAddUrl.invoke( classLoader, classPath.toURI().toURL());
System.out.println("added "+classPath);
}catch(Exception e){
e.printStackTrace();
}
}
Method methodAddUrl =
classClassLoader.
methodAddUrl.setAccessible(
methodAddUrl.invoke(
System.out.println("added "+classPath);
}catch(Exception e){
e.printStackTrace();
}
}
0 件のコメント:
コメントを投稿