I have been googling for some time, and everyone seems to have a different solution, none of which appear to be working for me.
I have tried both ProcessBuilder
One option is to handle ~
yourself:
String homeDir = System.getenv("HOME");
String[] cmd = { homeDir + "/path/to/shellscript.sh", "foo", "bar" };
Process p = Runtime.getRuntime().exec(cmd);
Another is to let Bash handle it for you:
String[] cmd = { "bash", "-c", "~/path/to/shellscript.sh foo bar" };
Process p = Runtime.getRuntime().exec(cmd);