英文:
Trying to make the object of a class, whose absolute path is known only
问题
File fi = new File("file:///home/abc/Desktop/test/out/production/test/");
URL url = fi.toURI().toURL();
URL[] urls = new URL[]{url};
URLClassLoader classLoad = new URLClassLoader(urls);
Class<?> v = classLoad.loadClass("test.out.production.test.Rout");
// Absolute Path of the class whose object should be created /home/abc/Desktop/test/out/production/test/Rout (Rout is the required class)
// But it is giving ClassNotFound Exception.
英文:
File fi = new File("file:///home/abc/Desktop/test/out/production/test/");
URL url = fi.toURI().toURL();
URL[] urls = new URL[]{url};
URLClassLoader classLoad = new URLClassLoader(urls);
Class<?> v = classLoad.loadClass("test.out.production.test.Rout");
Absolute Path of the class whose object should be created /home/abc/Desktop/test/out/production/test/Rout (Rout is the required class)
But it is giving ClassNotFound Exception.
专注分享java语言的经验与见解,让所有开发者获益!
评论