0

I'm trying to execute a network testing application via my Java application. Below is the code:

try {
    String file = new File("iperf3.exe").getCanonicalPath();
    String cmd[] = {file,"-c ping.online.net -P 20 -w 710000 -t"};
    Process p = Runtime.getRuntime().exec(cmd);

    BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));

    String line;
    while ((line = input.readLine()) != null) {
        lblConsole.setText(line);
        //System.out.println(line);
    }
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

I got an error saying that the application could not connect to the server. However, when I execute the command in my command prompt, there is no error.

May I know what could I have missed out here?

Nayuki
  • 17,911
  • 6
  • 53
  • 80
Adrian Tan
  • 33
  • 8

1 Answers1

0

Managed to solve this issue. It is mainly on how I executed the code in the cmd. Just updated to as below:

String file = new File("iperf3.exe").getCanonicalPath(); String cmd1[] = {file,"-c","ping.online.net","-P","10","-w","710000"};
Adrian Tan
  • 33
  • 8