groovy - java code to instantiate another java file -
i want write program dynamically invoke method inside java class (uncompiled) file name location given. i've used following code wasn't working.
//folder location of java file loaded string url = "c:/temp/testcases/test.java"; //name of java file loaded string classname = "test.java"; this.class.classloader.rootloader.addurl(new url(url+str)); class.forname(str).newinstance();
the above instance unable invoke method inside java file want load dynamically. error in it?
the class loader able load compiled classes. it's not able open java source files, compile them on fly, , load class.
moreover, class name not same file name.
Comments
Post a Comment