Kill a process with a PID Tag(s): Environment
With JDK9
public class KillProcess {
public static void main(String[] args) {
// PID
ProcessHandle.of(16728).ifPresent(ProcessHandle::destroy); // or ProcessHandle::destroyForcibly
}
}
For example, on a Windows Professionnal installation, you launch the taskkill utility :
Runtime.getRuntime().exec("taskkill /F /PID 827");
To retrieve the PID for the current Java process, see Get the current PID.
mail_outline
Send comment, question or suggestion to howto@rgagnon.com
Send comment, question or suggestion to howto@rgagnon.com