You can use ProcessBuilder as described below:
import java.io.BufferedReader; import java.io.InputStreamReader; public class PBTest { public static void main(String[] args) { ProcessBuilder pb = new ProcessBuilder("process1"); pb.redirectErrorStream(true); try { Process p = pb.start(); String s;
Then your java task is pretty simple:
<target name="run"> <java classname="PBTest" fork="true"></java> </target>
Application:
I am looking for a solution in ant (1), not in Java.
You can use any supported Apache BSF or JSR 223 language in the script task . I donβt see the possibility of using standard input and output directly, but you can use loadfile task to load properties from a file. Here is an example that gets the version number from the source file.
source share