Unable to instantiate a class using classloader
i load a class using ClassLoader but i am not able to create an object of that class.Here is the code.What is the problem?Help
Cloader = new URLClassLoader(new URL[] {new File(binfolderurl).toURI().toURL()},ClassLoader.getSystemClassLoader)开发者_Go百科;
Thread.currentThread().setContextClassLoader(Cloader);
Class clss = Cloader.loadClass("Someclass");
Object myobj = clss.newInstance();
You should be getting an Exception, describing what did not work. Did you?
The most likely reason is the class not having a default (no-arg) constructor, or that constructor being not public.
精彩评论