156

Possible Duplicate:
Maven Jetty plugin - how to control VM arguments?

In particular, I want to do something like this:

mvn -DjvmArgs="-Xmx2000m -Xms1000m -XX:PermSize=512m -XX:MaxPermSize=512m" jetty:run -Pmyprofile

Oh, and I would like to do this without having to modify the pom files or set any environment variables.. etc

3
  • 9
    you have to set the MAVEN_OPTS enviroment variable, but that can be done on the command line: MAVEN_OPTS="-Xmx2000m" mvn jetty:run
    – Thilo
    Commented Sep 21, 2012 at 6:29
  • 10
    A little late, but you can use the -DargLine switch rather than using a global value. Full example here Commented May 25, 2015 at 15:09
  • It's never too late! stackoverflow.com/a/68069089/5611377
    – ssimm
    Commented Sep 8, 2021 at 14:51

1 Answer 1

159

I think MAVEN_OPTS would be most appropriate for you. See here: http://maven.apache.org/configure.html

In Unix:

Add the MAVEN_OPTS environment variable to specify JVM properties, e.g. export MAVEN_OPTS="-Xms256m -Xmx512m". This environment variable can be used to supply extra options to Maven.

In Win, you need to set environment variable via the dialogue box

Add ... environment variable by opening up the system properties (WinKey + Pause),... In the same dialog, add the MAVEN_OPTS environment variable in the user variables to specify JVM properties, e.g. the value -Xms256m -Xmx512m. This environment variable can be used to supply extra options to Maven.

9
  • 3
    Is there a way to configure JVM argument in pom file?
    – nanosoft
    Commented Jan 4, 2017 at 13:05
  • 33
    @nanosoft No, as this would be to late (the JVM would have been started already). But since Maven 3.3.1 you can create a .mvn/jvm.config file with just the options in it. Commented Sep 28, 2017 at 9:45
  • 2
    is it possible to give it as runtime args Commented Dec 12, 2019 at 6:18
  • 3
    WinKey + Pause how have I never learnt this before?! Very useful Commented May 11, 2020 at 13:29
  • 1
    @MartinHöller .mvn/jvm.config only works during the build or when the fork count is zero (use -DforkCount=0 in command line) beauce a forked VM might be used during the tests.
    – gouessej
    Commented Aug 30, 2021 at 19:33

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