Killing Internet Browser opened with Runtime.exec

I am running Win NT 4.0 and I am successfully opening my HTML help using the following code:

String command = new String("cmd /K ");

command = command.concat("G:\editor\help\index.html");

Process p = Runtime.getRuntime().exec(command);

However, if I run p.destroy(), the browser window does not close. This means that the help remains open after the program exits and also that multiple help windows can be opened.

Does anyone know how to kill a browser opened with Runtime.exec()?

Thanks for any help you can offer,

Christopher Collins

Marineering Limited

[625 byte] By [ChrisNF] at [2007-9-26 1:52:20]
# 1

Did you try Runtime runtime = Runtime.getRuntime()

process.destroy();

runtime.exit();

I don't know myself if this will work, I know that a Process is an independent program, but I think it should get destroyed when you kill the JVM (ie. runtime.exit())

let me know

jmschrei

jmschrei at 2007-6-29 3:01:55 > top of Java-index,Desktop,Runtime Environment...
# 2

Thanks jmschrei,

I tried System.exit(0) and Runtime.getRuntime().exit(0) and neither succeeded in closing the internet browser process. I suspect that process.destroy() and runtime.exit(0) both are killing the instance of the command interpreter spawned by runtime.exec("cmd /K [URL]") and not actually the browser opened by that command. Therefore, I think that the process refers to the "cmd" and not the browser, which probably opens completely independently of my Java program, thus can't be closed by it.

Unforetunately, I don't know another way to open a browser.

If anyone has any additional suggestions, I would appreciate it. Many people in the forums seem to have asked this one, and there are no solutions I could find.

Christopher

ChrisNF at 2007-6-29 3:01:55 > top of Java-index,Desktop,Runtime Environment...