try{
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec("cmd /c netstat -ano | findstr 9090");
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(proc.getInputStream()));
String s = null;
if ((s = stdInput.readLine()) != null) {
int index=s.lastIndexOf(" ");
String sc=s.substring(index, s.length());
rt.exec("cmd /c Taskkill /PID" +sc+" /T /F");
}
JOptionPane.showMessageDialog(null, "Server Stopped");
}catch(Exception e){
JOptionPane.showMessageDialog(null, "Something Went wrong with server");
}
java - 如何在java中查找在端口号上运行的进程的进程ID
最新推荐文章于 2024-09-14 18:46:05 发布