package org.cipres.kepler.jrun; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import org.cipres.helpers.JRun; public class JRunTester4 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub final ArrayList argsFileLines = new ArrayList(); try { final FileReader argsFile = new FileReader("/Users/zhijieguan/work/ClustalW/argum.txt"); final BufferedReader reader = new BufferedReader(argsFile); String line; while ((line = reader.readLine()) != null) argsFileLines.add(line); } catch (final IOException ioErr) { ioErr.printStackTrace(); } // test4 is to test destroying the execution JRun test4 = new JRun(); test4.setExecutable("/Users/zhijieguan/work/ClustalW/clustalw"); // test4.setOutputFileName("/Users/zhijieguan/work/ClustalW/runout"); // test4.setErrorFileName("/Users/zhijieguan/work/ClustalW/error"); test4.setWorkingDirPath("/Users/zhijieguan/work/ClustalW/"); test4.setWaitForExecution(false); test4.setArguments((String[]) argsFileLines.toArray(new String[argsFileLines.size()])); try { System.out.println( test4.execute() ); } catch (final InterruptedException interruptedErr) { interruptedErr.printStackTrace(); } catch (final IOException ioErr) { ioErr.printStackTrace(); } if (test4.checkStatus()!=0) { test4.stopExecution(); System.out.println("I tried to stop the execution"); } else { System.out.println("Unfortunately the programs finished!"); } try { System.out.println( test4.checkStatus()); } catch (Exception ex) { System.out.println("Seems the execution is killed!"); ex.printStackTrace(); } } }