You have almost answered yourself. You need to launch this process in separate thread using either Runtime.exec() (http://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html) or some more sophisticated tool like so Apache Commons Exec http://commons.apache.org/proper/commons-exec/index.html
Method annotated with '@Before' or '@BeforeClass' annotation can be good place to do this. The best way would be to program extra helper class as singleton. This class will be responsible for launching the thread only in case it was not launched before, so you will have only one process for all the tests.
Edit: It should be something like:
@BeforeClass
public static void startProess() throws Exception {
SomeProcess .getInstance().startIfNotRunning();
}
public class SomeProcess {
private Thread thread;
private Process process;
private static SomeProcess instance = new SomeProcess ();
public static SomeProcess getInstance() {
return instance;
}
public synchronized void startIfNotRunning() throws Exception {
(...)
// check if it's not running and if not start
(...)
instance.start();
(...)
}
public synchronized void stop() throws Exception {
process.destroy()
}
private synchronized void start() throws Exception {
thread = new Thread(new Runnable() {
@Override
public void run() {
process = Runtime.exec("/path/yo/your/app");
}
});
thread.start();
// put some code to wait until the process has initialized (if it requires some time for initialization.
}
}