how to find process id for terminating the app

K

Krisp

Hi,

I am executing an exe using
Runtime.getRuntime().exec(cmd); on windows platform

cmd contains the command line to run the external exe.

How can i find the process id of this external program?
i want this process id to kill the instance after my program is
finished.

Thanks,
Krisp
 
A

Arne Vajhøj

Krisp said:
I am executing an exe using
Runtime.getRuntime().exec(cmd); on windows platform

cmd contains the command line to run the external exe.

How can i find the process id of this external program?
i want this process id to kill the instance after my program is
finished.

I don't think Java supports getting something as platform
specific as that.

But the Process object returned by exec do have a destroy
method that may be do what you want.

Arne
 
K

Krisp

I don't think Java supports getting something as platform
specific as that.

But the Process object returned by exec do have a destroy
method that may be do what you want.

Arne


ya i tried that destroy method but it doesnt work.

Thanks,
Krisp
 
A

Arved Sandstrom

ya i tried that destroy method but it doesnt work.

Thanks,
Krisp

The Javadocs do say that "the Runtime.exec methods may not work well for
special processes on certain native platforms, such as native windowing
processes, daemon processes, Win16/DOS processes on Microsoft Windows, or
shell scripts."

So it may well depend on what program you are calling.

I've had no problems myself on either Windows, Linux or Mac OS X using
Runtime.exec(). However, all of the programs I call are well-behaved
executables that if I exercise them on the command line always terminate
after doing what they are supposed to do.

AHS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,744
Latest member
CortneyMcK

Latest Threads

Top