Java equivalent of fork in Ant java task?

Ant The Java task provides a parameter forkthat, by definition, "if enabled, starts class execution in another virtual machine." Since we are dealing with a lot of data, setting this parameter saved us from running out of Java heap space.
We want to be able to do the same with the Java class. What would be the best way to achieve the functionality provided fork?

+3
source share
3 answers

Run another Java process. For example, using the ProcessBuilder class.

http://java.sun.com/javase/6/docs/api/java/lang/ProcessBuilder.html

, . , , .

java- , .

, , Process.waitFor().

+8

ant, fork - true, Execute, , ,

Runtime.getRuntime().exec(cmd, env);

org.apache.tools.ant.taskdefs.Java org.apache.tools.ant.taskdefs.Execute ..

+3

I think you can directly use the Ant API ... Ant can be used directly in the Java class. Javadoc is available in its binary distribution.

0
source

Source: https://habr.com/ru/post/1708255/


All Articles