My application launches a web browser to view various files. I use the
standard trick to launch them:
Process p = Runtime.getRuntime().exec( new String[] { "command.com",
"/c", "explorer", myfilename } );
I'm trying to limit the number of browsers launched at any one time to,
say, three. I thought I could just keep a List of the Processes returned
from this call, and before I launched a new one, see if any of the previous
Processes have exited, and don't launch if there are more than three that
haven't.
Unfortunately, the process seems to have an exit value right away, once
the browser is launched successfully. Is there any way to track the
actual browser process, and see if it is still running?
AdTHANKSvance,
--mark
Stanimir Stamenkov - 22 Dec 2004 16:51 GMT
[cross-posted to c.l.j.programmer, follow-up to c.l.j.programmer]
/Hegemony Cricket/:
> My application launches a web browser to view various files. I use the
> standard trick to launch them:
>
> Process p = Runtime.getRuntime().exec( new String[] { "command.com",
> "/c", "explorer", myfilename } );
The above would fail on any WinNT (i.e. NT4/2000/XP and up) system.
On these systems there's no "command.com" but "cmd.exe". AFAIK the
preferred method to start the default registered browser on all
Windows systems is by invoking:
rundll32 url.dll,FileProtocolHandler <url>
Where you need to substitute the <url> in the above line with the
requested URL. Here's an article on this one:
"Control browsers from your Java application"
<http://www.javaworld.com/javaworld/javatips/jw-javatip66.html>
> I'm trying to limit the number of browsers launched at any one time to,
> say, three. I thought I could just keep a List of the Processes returned
[quoted text clipped - 5 lines]
> the browser is launched successfully. Is there any way to track the
> actual browser process, and see if it is still running?
The above may actually help solving this issue, I'm not sure though.

Signature
Stanimir