package my.pid; import java.lang.management.ManagementFactory; public class MyPid { public static void main(String[] args) { String nameOfRunningVM = ManagementFactory.getRuntimeMXBean().getName(); int p = nameOfRunningVM.indexOf('@'); String pid = nameOfRunningVM.substring(0, p); System.out.println("Java app PID: " + pid); } }
No comments:
Post a Comment