rcp开发时动态加载jar
程序员文章站
2022-05-18 10:53:45
...
在使用eclipse rcp 开发时,需要动态加载jar包,使用如下代码解决
DefaultClassLoader defaultClassLoader=(DefaultClassLoader)Activator.class.getClassLoader();
ClasspathManager manager = defaultClassLoader.getClasspathManager();
ArrayList<String> paths = new ArrayList<String>();
paths.add("external:"+file);
manager.attachFragment(manager.getBaseData(),null,paths.toArray(new String[paths.size()]));