Jak pobrać PID w runtime’ie?
Jak pobrać PID w runtime’ie? Oto prosty sposób:
import java.lang.management.ManagementFactory; public class PID { public static void main(String[] args) { final String vmName = ManagementFactory.getRuntimeMXBean().getName(); final int position = vmName.indexOf('@'); final String pid = vmName.substring(0, position); System.out.println("Your PID is: " + pid); } }