我有一个 jar 的 UI 包装器。当从 UI 触发事件 'submitButton' 时,会调用以下方法来执行它。jar 在单独的进程中执行,但只有在调用进程(即 UI 服务器)停止后才会发送邮件。知道为什么吗?(当从 cmd 行执行时,jar 工作正常)。
public static String doSendMail(){
// Run a java app in a separate system process
Process process;
try {
ProcessBuilder pb = new ProcessBuilder("java", "-jar", "SendMail.jar", ">>", "test.log");
process = pb.start();
InputStream in = process.getInputStream();
InputStream err = process.getErrorStream();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "Success";
}