如何在依赖cmd的java中运行一个进程并等待其完成?

这个问题是我以前从未见过的。请在回答或引用其他帖子之前仔细阅读。

I have a java process that I am launching via 'Runtime.getRuntime().exec'. This is a "file.exe".There are two ways I am doing this,

1) Lanching the process in the background, such as Runtime.getRuntime().exec("C:../file.exe") which works fine in the background. The method .waitFor() returns 0 when this process is finished, which is OK, but the user never sees the process because it is running the background.

2) Launching the process via cmd. This is done as Runtime.getRuntime().exec("cmd /c start cmd.exe /K \"C:../file.exe\" "), which first displays the CMD window, and then runs "file.exe". However, .waitFor() returns 0 when cmd.exe is thrown and not when file.exe is executed.

What I want, is to open cmd so one can see file.exe execution (like in option 2), but at the same time return 0 via .waitFor() when file.exe has finished and not when cmd.exe has been thrown. Does anyone see a potential solution to this (if there is any)?

谢谢。