private static int getProcessId(Process process) { int PID = 0; if (process.getClass().getName().equals("java.lang.Win32Process") || process.getClass().getName().equals("java.lang.ProcessImpl")) { try { Field f = process.getClass().getDeclaredField("handle"); f.setAccessible(true); long handl = f.getLong(process); Kernel kernel = Kernel.INSTANCE; W32API.HANDLE handle = new W32API.HANDLE(); handle.setPointer(Pointer.createConstant(handl)); PID = kernel.GetProcessId(handle); } catch (Throwable e) { Loggers.SERVER.error("PID PROBLEM " + e); } } return PID; }