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

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -