Skip to content

Instantly share code, notes, and snippets.

@kunals201
Created May 16, 2019 11:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kunals201/a0ea90764221e54d16dabea9fcacf726 to your computer and use it in GitHub Desktop.
Save kunals201/a0ea90764221e54d16dabea9fcacf726 to your computer and use it in GitHub Desktop.
Destroy running Process by taking process id
package com.knoldus;
import java.util.Optional;
public class DestroyProcess {
public static void main(String[] args) {
final Optional<ProcessHandle> processHandle = ProcessHandle.of(9767);
if(processHandle.isPresent())
{
processHandle.get().destroy();
System.out.println("Process Destroyed Successfully !!");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment