I'm trying to kill the running port(8080)
by using the below java
code. But, it seems the code is not working.
Process process = Runtime.getRuntime().exec("netstat -aon | find 8080");
InputStream ips = process.getInputStream();
InputStreamReader isr = new InputStreamReader(ips);
BufferedReader br = new BufferedReader(isr);
String value = null;
while ((value = br.readLine()) != null) {
System.out.println(value);
}
I didn't find that anything got printed into output console. And not sure how to proceed further.
I want this code to work on windows
and linux
box. Is there any general solution to make this code work on both OS and how to kill the port using JAVA
?
Any leads?