I have a folder in this folder I have 4 .class file .I want load this files in my main program and call the methods .for one .class file I do like so:
File file = new File("/home/saeed/NetBeansProjects/java-test/build/classes");
URI uri = file.toURI();
URL[] urls = new URL[]{uri.toURL()};
ClassLoader classLoader = new URLClassLoader(urls);
Class clazz = classLoader.loadClass("com.test.NewClass");
And for invoke the method I do like so:
Object obj = clazz.newInstance();
System.out.println(""+obj.getClass().
getMethod("echo",String.class).invoke(obj, "Saeed"));
Now I have one more than .class in the folder .How can I load and invoke their methods? Can anyone help me?