0

I am trying to do build one of my projects using ant and I am getting following error

    [javac] javac: invalid flag: -J-Xms512m
    [javac] Usage: javac <options> <source files>

And this is what my .xml file looks like

Relevant portion only:

   <javac srcdir="MY_SRC_DIR">
            <compilerarg value="-J-Xms512M" />
            <compilerarg value="-J-Xmx512M" />
   </javac>

Tried following other options and I still see same error as above

[1] Tried a white space between -J and -Xms

[2] Tried using compilerarg line="-J-Xms512m -J-Xmx512m"

[3] Tried using memoryinitialsize and memorymaximumsize instead of compiler options.

javac -version javac 1.6.0_51

Tried this on command line and it works fine

 javac -J-Xms512m -J-Xmx512m Blah.java

Any help would be appreciated

7
  • Tried that too, didn't work either
    – user462455
    Sep 4, 2013 at 22:45
  • Same error [javac] javac: invalid flag: -Xms512M
    – user462455
    Sep 4, 2013 at 22:47
  • except now it says an invalid flag -Xms<size>
    – user462455
    Sep 4, 2013 at 22:48
  • -Xmx and -Xms with -J work on command line, so I guess they are arguments for compiler(javac)
    – user462455
    Sep 4, 2013 at 22:48
  • What is the value of your fork attribute for the javac ant task? I bet it must be set to true for this to have any chance of working because the only way the compiler min/max memory settings could change is if a different JVM is forked to compile. Looks like default value for fork=false. Try setting it to true.
    – Keith
    Sep 4, 2013 at 22:51

2 Answers 2

0

Looks like you want the memoryInitialSize and memoryMaximumSize attributes. See the Javac Task manual page.

Try with:

<javac
  memoryInitialSize="512m"
  memoryMaximumSize="512m"
  fork="true"
  ...>
    <!-- stuff -->
</javac>
1
  • Like I mentioned in my question details I already tried this, and I get a similar error javac: invalid flag: -J-Xms512m. I guess that is because memoryInitialSize gets mapped to -J-Xms512m
    – user462455
    Sep 4, 2013 at 23:44
-1

Why are you trying to set heap size limits on the javac compiler? -Xms and -Xmx are arguments for the java runtime java and not the java compiler javac.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.