/* * Java進程與子進程交互 * */ public class RunyimeDemo { public static void main(String[] args) { Runtime run = Runtime.getRuntime(); try { run.exec("notepad.exe"); } catch (Exception e) { e.printStackTrace(); } } }
運行結果:
打開了記事本程序
================================================
通過Runntime類可以爲開發者執行操作系統的可執行程序