开发者

Unable to instantiate a class using classloader

开发者 https://www.devze.com 2022-12-23 21:04 出处:网络
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

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

精彩评论

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

关注公众号