1 public class GetProcessInfo { 2 3 public static void main(String... args) { 4 int pid = Process.getCurrentPid(); 5 System.out.println( " PID = " + pid ); 6 if (pid <= 0) { 7 throw new Exception("Test Failed: Invalid current PID: " + pid); 8 } 9 10 String currentProcessName = new Process().getCurrentProcessName(); 11 String currentProcessNameByPid = new Process().getProcessName( pid ); 12 if (!currentProcessName.equals(currentProcessNameByPid)) { 13 throw new Exception("Test Failed: current process name ( " + currentProcessName + " ) does not match process name by pid ( " + currentProcessNameByPid + " )"); 14 } 15 } 16 }