title: Shell Arguments Not Being Passed to Java Class Correctly
body: <p>I wrote a short shell script that takes in parameters, checks them (because they're "optional" and if they're empty it sets default values), and them passes them to a Java class on the server.  Basically, like so:</p>
  
  <pre><code>x=${2:-'Default'}
  y=${3:-'Default Name Has Spaces'}
  echo \"$x\"
  echo \"$y\"
  java -d64 -ms3G -mx3G -cp example.jar -Djava.security.policy=policy com.example.JavaClass $1 \"$x\" \"$y\"
  </code></pre>
  
  <p>However, when the shell makes the call to the Java class, I just get back that (if the above defaults are used) "argument Name is not recognized". </p>
  
  <p>With the escaped-quotes around the <code>echo</code> on lines 3 and 4, I see that the variables ARE set correctly and they're echoed out like so: <code>"Default"</code> and <code>"Default Name Has Spaces"</code>, yet even with the escaped quotes in the Java call, they seem to be passing as more than two arguments -- it's like they're being passed as <code>java -d64 -ms3G -mx3G -cp example.jar -Djava.security.policy=policy com.example.JavaClass $1 Default Default Name Has Spaces"</code> which fails because the Java class only expects three total arguments.</p>
  
  <p>Does anyone have any ideas as to why or how to make the arguments pass correctly?</p>