13

I use "mvn exec:java" to run my program:

mvn exec:java -Dexec.mainClass="..." -Dexec.args="..."

I didn't find to change the maximum memory allocation to the JVM.

I tried -Dexec.commandlineArgs="..." but that didn't work...

Erel Segal-Halevi
  • 33,955
  • 36
  • 114
  • 183
  • 1
    http://stackoverflow.com/questions/13598949/maven-heap-space did you try this? MAVEN_OPTS – Zeus Jan 30 '14 at 22:10
  • Or, as per this http://mojo.codehaus.org/exec-maven-plugin/java-mojo.html#arguments you may have to add heap arguments to the 'arguments' – Zeus Jan 30 '14 at 22:12
  • This answer: http://stackoverflow.com/a/13599101/827927 "export MAVEN_OPTS="-Xmx512M" did the trick. Thanks! – Erel Segal-Halevi Jan 30 '14 at 22:17

2 Answers2

19

<commandlineArgs> (or -Dexec.args when given in the CLI) is for specifying the arguments given to the program, not the JVM.

As exec:java executes a Java program in the same VM as the Maven one, just change the Maven JVM memory settings (so MAVEN_OPTS) to get more memory for your exec:java command.

Tome
  • 3,234
  • 3
  • 33
  • 36
3

You can use exec:exec to run java in separate process. Then you can specify any arguments (including -Xmx). See https://stackoverflow.com/a/25442840/658606 for more details and for an example .

Community
  • 1
  • 1
ivan.a.bovin
  • 1,133
  • 10
  • 17