I have an Ant task to call a java process that takes a file on the command line. I can pass the file directly to the java program but I can’t figure out how to make Ant take the file on the command line.
Here’s what I’ve got:
<target name="FileProcessor" description="Process a specified file">
<run-standalone name="CheckClearer" main-class="com.blah.FileProcessor">
<args>
<arg value="${file}"/>
</args>
</run-standalone>
</target>
When I run this I get
Exception in thread "main" java.io.FileNotFoundException: ${file} (No such file or directory)
(I searched all over for an answer to this as I’m sure I’m just missing something simple but didn’t find anything. If there’s an SO answer out there, please point me to it. Thanks)
I’ve never seen the
<run-standalone>task, but you can just use<java>to launch a Java class and nested<arg>to specify the arguments to the class.Example:
Of course, make sure that the value in the property
${file}actually exists first.