title: Executing shell-script with parameters from java
body: <p>I have been googling for some time, and everyone seems to have a different solution, none of which appear to be working for me.</p>
  
  <p>I have tried both <code>ProcessBuilder</code> and <code>Runtime</code>. Both calling the <code>.sh</code> file directly and feeding it to <code>/bin/bash</code>. With no luck.</p>
  
  <p>Back to basics, my current code is as follows;</p>
  
  <pre><code>String cmd[] = { "~/path/to/shellscript.sh", "foo", "bar" };
  Process p = Runtime.getRuntime().exec(cmd);
  </code></pre>
  
  <p>Which is giving a <code>No such file or directory</code> error, despite that manually running;</p>
  
  <pre><code>~/path/to/shellscript.sh foo bar
  </code></pre>
  
  <p>Works perfectly from bash.</p>
  
  <p>I need to keep the <code>~</code> because this shellscript exists in slightly different forms for three different users.</p>