I currently have the following directory tree structure:
CLASSES -> ClassOne ->package -> my ->App.class I would like to load the App.class from my local drive. I looked around, particularly stackoverflow, and most seem to suggest that I should use the URLClassLoader.
In order to do this, I used this following code:
However, I get a ClassNotFoundError. Can anybody help me please.
String url = "file://" + classOneFolder.getAbsolutePath(); //Where classesFolder is a File representing the ClassOne directory URL[] urls = {new URL(url)}; urlClassLoader = URLClassLoader.newInstance(urls); //class loader needs the fully classified class name. Therefore: Class appClass = urlClassLoader.loadClass("package.my.App");