Here is an overview of what I am doing. I have a Java Swing application. On it I have a button called 'Ping'. What I want to happen is that when I click on the button Ping then it should ping a particular server. The server IPAddress details are in a text box.
So this is the code I have.
try {
Process p = Runtime.getRuntime().exec(strbf.toString());
if (Action.equalsIgnoreCase("PING"))
{
BufferedReader in = new BufferedReader(
new InputStreamReader(p.getInputStream()));
String line = null;
while ((line = in.readLine()) != null)
{
mylogger.logInfo("Servers", "actionToBeTaken", "Ping line is" + line);
}
}
So the output of the ping goes into a logger file. Everything is good so far. But I don't want this behavior. Note that if I type in ping into the windows run prompt or dos prompt then a seperate ping window pops up. This is the way I want my code to function. Click on a button and the window automatically pops up. What changes do I make to my code? I tried different things but it does not seem to work. For example the below does not work. I don't know where the output of the ping command is getting eaten up. How do I ensure the command prompt windows pops up and the ping output is visible there.
try {
if (Action.equalsIgnoreCase("PING"))
{
Runtime.getRuntime().exec(strbf.toString());
}