Thread View: borland.public.jbuilder.java.api
3 messages
3 total messages
Started by David Huang
Sat, 22 Nov 2003 02:27
Help on Process.destroy(),......why it doesn't work.
Author: David Huang
Date: Sat, 22 Nov 2003 02:27
Date: Sat, 22 Nov 2003 02:27
29 lines
1506 bytes
1506 bytes
hi all,
I have a program that does Runtime.exec(a bat/sh script file), which will
start a java process.
When I tried to destroy this process using process.destroy(), it does not
work.
Can some one help me ..?
my code looks like this:
Runtime rt = Runtime.getRunTime();
Process process = rt.exec(MyScriptFile);
try{
Thread.sleep(5000); //just waiting for process started by my script
file to initialize
}catch(Exception ex){}
process.destroy();
Thanks
David
Re: Help on Process.destroy(),......why it doesn't work.
Author: David Huang
Date: Sat, 22 Nov 2003 08:21
Date: Sat, 22 Nov 2003 08:21
43 lines
1848 bytes
1848 bytes
Hi all,
I found the reason is like this:
I using
> Process process = rt.exec("explorer");
but at win2k explorer can not be killed by this way. If I changed to
iexplorer it will work.
Thanks
David
"David Huang" <dayicool@sina.com> д���ʼ�
news:3fbec8a7$1@newsgroups.borland.com...
> hi all,
>
> I have a program that does Runtime.exec(a bat/sh script file), which will
> start a java process.
>
> When I tried to destroy this process using process.destroy(), it does not
> work.
>
> Can some one help me ..?
>
> my code looks like this:
>
>
>
> Runtime rt = Runtime.getRunTime();
>
> Process process = rt.exec(MyScriptFile);
>
> try{
>
> Thread.sleep(5000); //just waiting for process started by my script
> file to initialize
>
> }catch(Exception ex){}
>
> process.destroy();
>
> Thanks
> David
>
>
Re: Help on Process.destroy(),......why it doesn't work.
Author: John McGrath [TeamB]
Date: Sat, 22 Nov 2003 16:54
Date: Sat, 22 Nov 2003 16:54
21 lines
1736 bytes
1736 bytes
On 11/21/2003 at 9:27:28 PM, David Huang wrote:
> I have a program that does Runtime.exec(a bat/sh script file), which
> will start a java process.
>
> When I tried to destroy this process using process.destroy(), it does
> not work.
It sounds like the program you are starting is a shell, and then that
shell is starting the Java process. The Process object you get back
refers to the shell, not the Java process. So you are destroying the
shell, if it has not already terminated, and not the Java process.
--
Regards,
John McGrath [TeamB]
---------------------------------------------------
Before sending me e-mail, please read:
http://www.JPMcGrath.net/newsgroups/e-mail.html
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads