>In other words, in my application I want to determine if mysql is
>running. Should I do this by 'Runtime.getRuntime().exec()'? Is there a
>better way?
If you can do it in C, a bit of JNI glue will get it much faster.
see http://mindprod.com/jgloss/jni.html

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
> Does anybody know of a good way to determine the PID for a Linux system
> process from within Java?
>
> In other words, in my application I want to determine if mysql is
> running. Should I do this by 'Runtime.getRuntime().exec()'? Is there a
> better way?
Parsing the output of e.g. ps or more conveniently pidof is probably the
easiest thing to do, but be sure to read the manpages of those commands
carefully before using the info to do anything potentially dangerous. If
you have something against that solution, you could scan the /proc file
system by hand, and examine e.g. /proc/[pid]/stat, /proc/[pid]/exe among
other things, but keep in mind that the output may change between kernel
versions, so this could/will be hard to maintain.
I also suggest you ask your question in a linux group, try
comp.os.linux.development.apps.
Daniel Sjöblom
skip - 23 Oct 2005 03:00 GMT
>>Does anybody know of a good way to determine the PID for a Linux system
>>process from within Java?
[quoted text clipped - 15 lines]
>
> Daniel Sjöblom
Parsing pidof works well and is (for me) the simplest option. Thank you.