I'm trying to run a jar within a java program and capture its stdout. I want to do this to avoid the JVM startup cost every time the jar is run. What is the simplest way to do this?
I started by modifying Java's JarClassLoader and adding a SecurityManager subclass to that to prevent system exits. The JarClassLoader is a subclass of URLClassLoader, and looks up the main class in the jar and then executes the main function there. But now I'm getting InvocationTargetExceptions when I try to execute that function even though I'm passing the correct arguments. Anyone with an idea of where to go from here?
Is there a simpler way to do this?