Home > Back-end >  Dynamic loading of the jar is not an error in the getMethod also did not return
Dynamic loading of the jar is not an error in the getMethod also did not return

Time:12-22

String filePath="test. The jar";
File file=new File(filePath);
URL the URL=file. ToURI (.) toURL ();
URLClassLoader loader=new URLClassLoader (new [URL] {URL});
String className="com. My. Test".

Class<?> ProcessorClass=loader. LoadClass (className);
The Object obj=processorClass. NewInstance ();
Method=processorClass. GetMethod (" getData ", String class, BodyBuf. Class)
Method. The invoke (obj, "12345", buf);

When you perform to processorClass. The getMethod stopped, that there is no return, no abnormalities,
  • Related