public Exit launch ( Class mainClass , String ... args ) { jvmArgs = configureArguments ( mainClass , args ) ; try { Runtime rt = Runtime . getRuntime ( ) ; Process pr = rt . exec ( jvmArgs ) ; // If it exits too quickly it might not get any error messages if it crashes right away // so the work around is to sleep Thread . sleep ( 500 ) ; BufferedReader input = new BufferedReader ( new InputStreamReader ( pr . getInputStream ( ) ) ) ; BufferedReader error = new BufferedReader ( new InputStreamReader ( pr . getErrorStream ( ) ) ) ; // print the output from the slave if ( ! monitorSlave ( pr , input , error ) ) { if ( killRequested ) return Exit . REQUESTED ; else return Exit . FROZEN ; } if ( pr . exitValue ( ) != 0 ) { return Exit . RETURN_NOT_ZERO ; } else { return Exit . NORMAL ; } } catch ( IOException | InterruptedException e ) { throw new RuntimeException ( e ) ; } }
Launches the class with the provided arguments . Blocks until the process stops .