I wanted to know How to get processId of calling process in Java??
I know processId is platform specific but i wonder if JAVA supports a library or function for getting processId independent of platform??
You need to use JNI. In short:
- write a native method
- use javah to create the header (.h) file
- write a matching .c source file with the implementation
- compile it (search a bit on how to do this for different operating systems)
- add a System.loadLibrary call to the class to load the library
- make sure the .dll (for Windows) or .so (for Linux) is found as part of the "java.library.path" system property
subject: How to get processId of calling process in Java