private static String getPID ( ) { String vmName = ManagementFactory . getRuntimeMXBean ( ) . getName ( ) ; return vmName . substring ( 0 , vmName . indexOf ( "@" ) ) ; }
Returns process id . Note that Java does not guarantee any format for id so this is just a common heuristic .