java - Netbeans project still running when using `Runtime.getRuntime().exec("explorer.exe");` -
i'm working on (non-malicious) screen-locking sort of swing application, , i've adapted code martijn courteaux's answer @ use java lock screen this. problem when use runtime.getruntime().exec("explorer.exe");
reopen explorer process @ program closing, netbeans thinks project still running because resulting explorer.exe running. cmd prompt , jcreator don't have issue.
can give example of preferred way call command explorer.exe
avoid happening netbeans?
edit: close explorer process @ start of program (which includes taskbar). when run explorer, it's not open windows explorer window (which works totally fine given answers) restore regular windows ui.
the problem runtime@exec
waiting child process exit. default behavior.
if want execute parentless process (a process in parent process can terminate though child still running), need little more creative.
we use...
"cmd /c start /b /normal " + yourcommand
i highlight recommend using processbuilder
makes easier build , execute external commands.
something like...
processbuilder pb = new processbuilder("cmd", "/c", "start", "/b", "/normal", "explorer.exe"); pb.start();
for example....
nb run netbeans , program exited after/as explorer opened.
there 1 little draw back. doesn't long file names. you'll need find way produce short file names/paths work. forced use jni solution this
Comments
Post a Comment