ANT JAVAC failed with “error=87, The parameter is incorrect”

Leave a comment

March 26, 2010 by huionn

Today I encountered a weird problem, the ant build that always worked, suddenly failed with “ CreateProcess error=87, The parameter is incorrect”.

Clueless… I googled and found which mentioned that setting forked=”false” can solve the problem.
But the root cause remains a mystery to me…

At home, I spent some times trying to dig it out and found this…

What is the command line length limit?

The maximum command line length for the CreateProcess function is 32767 characters. This limitation comes from the UNICODE_STRING structure…

It seems like the arguments passed to javac have exceeded the limit (or other limit incurred by cmd) and was truncated. I assume this is supposed to be the root cause and I cannot prove it at home…

Better solution from

<tempfile property="temp.file" deleteonexit="true"/>
<concat destfile="${temp.file}">${apt.sourcepath}</concat>
<exec executable="${apt.home}/bin/apt">
<arg line="-s ${generated-source-dir}"/>
<arg line="-d ${generated-classes-dir}"/>

<arg line="@${temp.file}"/>
<delete file="${temp.file}"/>

This solution is based on JAVAC Command Line Argument Files (


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: