Java tutorial
//package com.java2s; public class Main { public static int getPid(Process process) { int pid = 0; String pname = process.getClass().getName(); if (pname.equals("java.lang.ProcessManager$ProcessImpl")) { try { java.lang.reflect.Field f = process.getClass().getDeclaredField("pid"); f.setAccessible(true); pid = f.getInt(process); } catch (Throwable e) { } } return pid; } }