Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法使用java停止正在运行的进程?我正在使用这段代码来运行命令:
Process process = Runtime.getRuntime().exec(String.format("cmd /c %s", command));
之后,我需要结束/停止/终止它。
有谁知道该怎么做?
Process中有一个destroy()方法,可以使用。
公共抽象无效销毁()
杀死子进程。此 Process 对象所代表的子进程被强制终止。