swing - Runtime exec launch application in background java -


when run following code, notepad getting launched in background instead of foreground

runtime rt = runtime.getruntime(); try {     rt.exec("notepad.exe"); } catch (ioexception ex) { } 

example:

from java desktop application, trying launch "notepad.exe". notepad getting launched behind application.

i see notepad should appear in foreground.

could please me resolve it?

the following open both files , executables (.exe):

java 1.6 , above:

try {    desktop.getdesktop().open(new file("notepad.exe")); } catch (exception e) {    e.printstacktrace(); } 

java 1.5 , under, without external library (windows only):

try {    runtime.getruntime().exec("cmd /c \"notepad.exe\""); } catch (exception e) {    e.printstacktrace(); } 

i tested 1.5 solution opening excel files not opening executable files, i'm guessing work to.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -