First, the way to run the program is as follows:
- Use "jar -xv TheProgram.jar" to unpack the JAR file
- Open the the MANIFEST.mf file in an editor and look for the "Main-Class" entry. That gives you a class name; e.g. "com.example.TheProgramMain"
Now write a class like this:
import com.example.TheProgramMain;
public class MyClass {
...
public void runIt() {
String[] args = ...;
TheProgramMain.main(args);
}
}
(You could automate that, i.e. using reflection, but there's not a great deal of point.)
That's the easy bit. The hard bit is going to be intercepting the output from the existing program so that you can post-process it. How you do that will depend on how the existing program works ...
Note that if you understood the internal design of the program, you could potentially figure out other ways to "drive" it; e.g. by instantiating classes and calling public instance methods to do the processing without writing the output.