Java Class.forName() from distant directory

Use an URLClassLoader for this. The code might be something along the lines of:

File f = new File("C:/dir");
URL[] cp = {f.toURI().toURL()};
URLClassLoader urlcl = new URLClassLoader(cp);
Class clazz = urlcl.loadClass("distantinterfaces.DistantClass");

Leave a Comment