import java.net.URLClassLoader;
public class MyTest{
public static void main(String[] args) throws MalformedURLException, ClassNotFoundException, InstantiationException, IllegalAccessException{
URL urls = new URL[]
URL[] urls = {new URL("file:///usr/home/foo/"), new URL("file:///usr/home/foo/lib/foo.jar")};
URLClassLoader classLoader = new URLClassLoader(urls);
Class myClass = classLoader.loadClass("com.mud.blah.SomeClass");
myClass.newInstance();
}
}
Suppose I have a main class, an interface, and a few concrete implementations of the interface all in the same directory. When the main class is run, it checks the local directory for any of the implementation .class files and loads them with URLClassLoaders. It works fine.
I then pack a manifest file, the main .class, and the interface .class into an executable .jar file placed in the same directory. I leave the implementation .class files outside of the .jar. This time, when the .jar is run, it finds the implementation .class files, but it throws a ClassNotFound exception when it tries to load them. I suspect the reason why is relatively simple, but I can't seem to figure it out. Does anyone have a clue as to what might be wrong?
Thanks!
–Kaeden