|
Java™ by example!
|
|
|
How do I get the current process ID in JDK 1.5?
The following example is platform-dependent and was only tested with Sun's JVM 1.5.0 on Windows XP. It first shows you how to get it using the standard management API's and then using some reflection tricks and the undocumented sun.* classes.
Main.java (Using RuntimeMBean):
Main.java (Using reflection):
Note that I've written a DLL / so before to get the process ID using JNI in all JDK versions. It can be found here.
Further Information
Author of answer: Joris Van den Bogaert
Comments to this answer are only viewable by members. Login or become a member!
|
|
|
|
|