I want to span a new JVM process from a Java class.
I could use Runtime.getRuntime().exec(...)
but this is a very low level api.
I am looking for something that will wrap that Process
api for me in something a bit more convenient like:
MonitoredJavaProcess javaProcess = new MonitoredJavaProcess(MyMainClass.class, "-Xmx1g");
javaProcess.getGcLogStream();
javaProcess.getHeapSizeObserver();
// ...
javaProcess.waitForShutdown();
A bit context on what I am trying to do: I am running JUnit a test suite taht starts up an embedded Jetty server and runs some test against it. That means that the tested Jetty server threads and the junit test threads run in the same JVM. I need to run them i separate JVMs. I could use ant or maven or anything external to starup jetty and then run the test suite against it but it sound a bit of an overkill for my simple scenario.
Perhaps your approach is not the right one. Perhaps you should consider using JMX to monitor your JVMs instead?
Cheers,
What actually you are trying to do. May be you can look at java.lang.ProcessBuilder it might suite your need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With