I've searched some topics, but couldn't find the answer. What i need is just to set up an additional path for default ClassLoader.
Right now i have such class:
public class Loader extends ClassLoader {
public void setPath(String s) {
File file = new File(s);
try {
URL classUrl = file.toURI().toURL();
URL[] urls = new URL[]{classUrl};
ClassLoader ucl = new URLClassLoader(urls);
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
And i need to make method setPath to work in such a way:
Loader load = new Loader();
load.setPath(directoryName);
Class clazz = (ClassLoader) load.loadClass(className);
Can someone help me in achieving this? Thanks.