Hi All,
I am wondering whether it is possible to pass parameter to a Java program directly when executed through Ant. Below is an example of what I am referring to:
public class Fly {
public static void main(String[] args) throws IOException {
if (args[0].matches("(?:NORTH|SOUTH|EAST|WEST|north|south|east|west)")) {
.......
}
}
}
It is then possible to run Fly and supply the parameter using the following syntax after having successfully built it using Netbeans 7.0.1 & Java 1.7.0 on Windows 7:
java -jar C:/USERS/Jack/Fly/dist/Fly.jar SOUTH
However, I am looking for the equivalent command line to invoke the same program through Ant below:
C:\USERS\Fly>ant run SOUTH
Instead, I will need to define ${direction} in the Ant build file before passing the value as property:
ant run -Ddirection=SOUTH
This resulted in the following build run error:
BUILD FAILED
Target "SOUTH" does not exist in the project "Fly".
In short, I am looking for a way to pass the parameter directly to the Java application when running the application using Ant without having to customise the build
file by defining the parameter as property.
Thanks in advance,
Jack