Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>By default, <code>&lt;javac&gt;</code> runs in-process with Ant. It is a general limitation of Java that you can't adjust a JVM process' <code>Xms</code> and <code>Xmx</code> once that JVM process has launched. So, the error message that you are seeing is the software rejecting your attempt to violate this principle (using an unhelpful, unfriendly error message.)</p> <p>If, however, you specify the attribute <code>fork="true"</code> on the <code>&lt;javac&gt;</code> tag you <em>will</em> be able to specify a new <code>Xms</code> and <code>Xms</code>. This is because <code>fork</code> instructs Ant to launch a new JVM subprocess in which to run <code>javac</code>. Because the JVM process is new, it gives Ant an acceptable opportunity to specify <code>Xms</code> and <code>Xmx</code> for it.</p> <hr> <p>You might try something like this:</p> <pre><code>&lt;project name="project" default="all" basedir="[yourvalue]"&gt; &lt;target name="all"&gt; &lt;javac srcdir="[yourvalue]" destdir="[yourvalue]" fork="true"&gt; &lt;!-- javac requires that -Xmx and -Xms be prefixed with -J --&gt; &lt;compilerarg line="-J-Xms128m -J-Xmx512m" /&gt; &lt;/javac&gt; &lt;/target&gt; &lt;/project&gt; </code></pre> <p>(Notice I am using <code>compilerarg line=""</code> rather than <code>compilerarg value=""</code>. The <code>line</code> attribute lets you specify multiple space-separated arguments. The <code>value</code> attribute is for passing a single argument.)</p> <hr> <p>Ant will wait for the forked <code>&lt;javac&gt;</code> to exit, which happens after the <code>javac</code> process finishes its work (i.e. compiling). Ant then continues running the build script inside its own original JVM process. Ant will check if the forked <code>javac</code> failed or succeeded, and take the usual actions based on this information.</p> <hr> <p><strong>Performance</strong></p> <p>It's usually more performant to <em>not</em> fork <code>javac</code>, and instead simply tune the relevant memory settings for the initial Ant JVM overall. This is often (but not always) the best choice because launching a separate JVM is usually slower and takes more memory than simply allowing <code>javac</code> to run in-process.</p> <p>If you are using the Ant-provided <code>ant.bat</code> or <code>ant.sh</code> to launch Ant, an easy way to tune Ant's <code>Xms</code> and <code>Xmx</code> is to define the environment variable ANT_OPTS to contain the arguments you want. There many ways to set environment variables, but you could just edit <code>ant.bat</code>:</p> <pre><code>set ANT_OPTS=-Xms128m -Xmx512m </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload