title: Pass a command line argument to JAR in an Ant script
body: <p>I've got a executable <a href="http://en.wikipedia.org/wiki/JAR_%28file_format%29" rel="noreferrer">JAR</a> file. And I've got an <a href="http://en.wikipedia.org/wiki/Apache_Ant" rel="noreferrer">Ant</a> build script that compiles and then creates this JAR file. I would like a task to run the JAR file as well, but I've got a command line argument that needs to be passed to the JAR. It's a configuration file. The run target is below</p>
  
  <pre><code>&lt;target name="run"&gt;
      &lt;java jar="build/jar/ShoutGen.jar" fork="true"/&gt;
      &lt;arg line="/home/munderwo/workspace/ShoutGen-Java/ShoutGen.conf"/&gt;
  &lt;/target&gt;
  </code></pre>
  
  <p>When I try to do this and run it from within Eclipse I get</p>
  
  <pre><code>Buildfile: /home/munderwo/workspace/ShoutGen-Java/build.xml
  run:
       [java] No config file passed as an argument. Please pass a configuration file
       [java] Java Result: 16
  
  BUILD FAILED
  /home/munderwo/workspace/ShoutGen-Java/build.xml:24: Problem: failed to create task or type arg
  Cause: The name is undefined.
  Action: Check the spelling.
  Action: Check that any custom tasks/types have been declared.
  Action: Check that any &lt;presetdef&gt;/&lt;macrodef&gt; declarations have taken place.
  </code></pre>
  
  <p>The error output from Java is my coded error meaning "you didn't pass an config file as an argument" which backs up the ant error of "Problem: failed to create task or type arg".</p>
  
  <p>So how do you pass an argument to an executed JAR file from within Ant? Is this something your not supposed to do?</p>