Good day everyone, I write to see how I can do an Ipconfig and a ping in java netbeans by popup window in which I ask the user the ip you want to ping, I currently have it to appear by console but I can not pass it to appear by window emergent. The code is as follows:
package ping;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import javax.swing.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class ping2 {
public static void runSystemCommand(String command) {
try {
Process p = Runtime.getRuntime().exec(command);
BufferedReader inputStream = new BufferedReader(new InputStreamReader(p.getInputStream()));
String s = "";
// reading output stream of the command
while ((s = inputStream.readLine()) != null) {
System.out.println(s);
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
String ip = "192.168.40.215";
runSystemCommand("ping " + ip);
}
}
I appreciate if someone can help me.