开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜