I'm working on a program where I want to loop through several config files, and with each file, call a class with that filename as an argument and wait for it to finish. Currently I am doing:
for (int i = 1; i <= 3; i++){
String[] a = new String[1];
a[0] = "data/config" + i + ".xml";
edu.cwru.sepia.Main2.class.getMethod("main", String[].class).invoke(null, (Object)a);
}
However, what happens is that the class only gets called once, and then the entire program stops. I think there is an exit line in the class, but since it is a JAR file I can't be sure and I can't edit it.
Let's assume that is the case; how would I get around that to do what I want? i.e. after the invocation ends with the exiting, my outer loop method continues and just calls the class again with the next argument.