Gettting the process id for a VM ...

Tim Panton - Westhawk Ltd tpanton at ibm.net
Sat Nov 12 19:29:10 PST 2005


the simplest way is to edit your 
startup scripts to say

exec java -DPID=$$ MyMainClass

then you can get the pid with System.getProperty("PID")

But you must ensure that exec is
used throughout any shell scripts.

Alternatively if your ?nix supports
/proc/self/stat, (like red hat 6.0)
then read that file, the first number
is the processID. This is more reliable, but less portable.


Tim

David Alexander Lestani <david at FotonInfo.com.br> wrote:
__________
>Hi all,
>
>Does anyone have a solution for extracting the operating system process id
>for a VM within an executing Java application. My investigations have shown
>that it is not implimented in the JDK API since it is platform dependent. If
>anyone has done some JNI development that they would like to share or other
>aditional pointers your help would be greatly appreciated. We are using the
>JDK 1.2.2 for AIX and NT.
>
>Kind regards,
>David
>
>__________________________________
>David Alexander Lestani
>Analista de Sistemas
>mailto:david at fotoninfo.com.br
>+55 61 328 5060 (R. 239)
>
>Fóton Informática e Serviços Ltda.
>http://www.fotoninfo.com.br 
>
>---
>To unsubscribe, mail advanced-java-unsubscribe at xcf.berkeley.edu
>To get help, mail advanced-java-help at xcf.berkeley.edu
>
---
URL http://www.westhawk.co.uk/

---
To unsubscribe, mail advanced-java-unsubscribe at xcf.berkeley.edu
To get help, mail advanced-java-help at xcf.berkeley.edu



More information about the Advanced-java mailing list