I want to run a jar from a java class, how could I do that? Something like:
public static void main(String[] args) {
Process process = Runtime.getRuntime().exec("java --jar grok.jar");
}
I’d be running this from within my IDE, eclipse. I’m not sure how to use the returned process to check the result of the command. It would also be nice if I could direct the output of the jar to a location of my choosing. This could probably be accomplished using “process.getOutputStream()”, but since the jar will launch a blocking process, not sure how that would work?
Thanks
The question is already answered here. Look at this answer for example, it should give you an idea on how to start a process and get the output as an InputStream.