0
if(Client.OS.equalsIgnoreCase("OSX")){
        try {
            Process process = Runtime.getRuntime().exec(Client.OSX_EXE);
        } catch (IOException e) {
            e.printStackTrace();
        }
}
else{
        try {
            Process process = Runtime.getRuntime().exec(Client.WINDOWS_EXE);
        } catch (IOException e) {
            e.printStackTrace();
        }
}

So I'm opening an application within a Java application, and it works as expected on Mac, however on windows, it makes the application on the sub process stop responding and crash. I tried running the Windows executable by itself and it works fine performing the same tasks.

Zera42
  • 2,592
  • 1
  • 21
  • 33
  • You need to capture the error stream and see if it gives any key output to you. In fact you need to handle all streams so as not to run out of buffer space. Also are you sure that you're using the right directory for your app? – Hovercraft Full Of Eels Mar 25 '18 at 13:25
  • 1
    Also, side question: why aren't you using a ProcessBuilder? – Hovercraft Full Of Eels Mar 25 '18 at 13:26
  • @HovercraftFullOfEels I was, but I changed to this to see if it was working (I left it in for this example, because both should be the same, and considering I'm not using any extra arguments, it should be okay at the moment). They both result in the same issue. Also I'll try to handle the buffer streams. I'm using the right directory because the application in question works, however it crashes after I use it. (doesn't happen on a mac) – Zera42 Mar 25 '18 at 14:16
  • OK, handle the streams and see if any key information comes back to you, then please let us know. – Hovercraft Full Of Eels Mar 25 '18 at 14:21
  • @HovercraftFullOfEels, I handled the streams and it works perfectly now. (Just reading the log, and appending it to the parent process) Weird. – Zera42 Mar 25 '18 at 15:42
  • No, nothing weird about it and in fact expected since Windows allows for small buffers for the streams. When they get filled due to your not handling them, the programs can go belly up. This is a known issue. Please read [this dated but still appropriate article](https://www.javaworld.com/article/2071275/core-java/when-runtime-exec---won-t.html) for more details on this. – Hovercraft Full Of Eels Mar 25 '18 at 16:18
  • Thank you! I generally use Mac only for development and testing, and recently got a Windows machine to test on, and ran into a lot of issues. I'll take a read. – Zera42 Mar 25 '18 at 16:56

0 Answers0