Java examples for Native OS:Shell Command
get Pid
//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);//from w w w. j a v a 2 s . c o m pid = f.getInt(process); } catch (Throwable e) { } } return pid; } }