I call a runtime execution on OSX adding “/bin/bash”, “-c” before the command, such as:
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec(new String[] { "/bin/bash", "-c", cmd });
I know that it is different for Windows and Linux. How can I make sure that my runtime command works on multi-OS?
Thank you.
Use something like:
Disclaimer: This is just orientative. There are still many corner cases (e.g. FreeBSD) that you need to test to get correct behavior.