你要等待进程结束,这是WAITFOR()这样的
public void executescript() { try { ProcessBuilder pb = new ProcessBuilder( "myscript.sh"); Process p = pb.start(); // Start the process. p.waitFor(); // Wait for the process to finish. System.out.println("script executed successfully"); } catch (Exception e) { e.printStackTrace(); }}


