我正在尝试从我的Java函数调用bat文件。看起来像我调用bat文件的方式有些问题。不从该方法调用批处理文件。任何帮助将不胜感激。
private static void Run_Main() throws InterruptedException, SQLException, IOException {
int set_value=0;
while ((set_value=Find_Flag()) !=0){
System.out.println("Set_Value"+set_value);
System.out.println("Staging load is not completed ..Revisiting after 15 minutes....");
Thread.sleep(900000);
set_value=Find_Flag();
}
System.out.println("Staging load is Completed and launching Proudction Load now");
//Runtime.getRuntime().exec(new String[] { "cmd.exe", "/c", "C:/exec/DW_Init_Load.bat" } );
String filePath = "C:/exec/DW_Init_Load.bat";
try {
Process p = Runtime.getRuntime().exec(filePath);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("Production Load is finished");
}
我很想知道我在代码中犯了什么错误
答案 0 :(得分:0)
添加p.waitFor()帮我解决了这个问题。最初,该块不等待该过程完成。