我正在Linux/Ubuntu中工作。我想在通過我的Java代碼,它看起來像下面通過java代碼運行java程序
ProcessBuilder pb = new ProcessBuilder("/usr/lib/flume-ng/bin/flume-ng",
"agent",
"-f",
"/home/c4/Flume/New/ClientAgent.config",
"-n",
"clientAgent");
pb.start();
,但我得到unreported exception java.io.IOException; must be caught or declared to be thrown pb.start();
作爲錯誤輸出運行的過程。請告訴我如何運行我的過程。謝謝。
請仔細閱讀本教程:http://docs.oracle.com/javase/tutorial/essential/exceptions/handling.html –
由於start方法拋出IOException,你需要或者把它們放在try catch塊或者添加拋出IOException來擺脫問題 –