metaphizix
metaphizix

Reputation: 91

"Invalid maximum heap size" when running Maven

I'm having problems setting up maven. I'm using windows 7 64 bit with 4 GB of RAM.

I get this error when trying to run mvn:

Invalid maximum heap size: -Xmx512m.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

Here are my user variables:

JAVA_HOME=C:\Program Files\Java\jdk1.7.0_55

M2=%M2_HOME%\bin

M2_HOME=C:\Program Files\Apache Software Foundation\apache-maven-3.2.1

MAVEN_OPTS=-Xms256m -Xmx512m

Path=%M2%;%JAVA_HOME%\bin

Upvotes: 7

Views: 14567

Answers (4)

Micah Stubbs
Micah Stubbs

Reputation: 1927

On MacOS a version of @adriaan-koster's answer works.

In your ~/.zshrc (or .bashrc or .bash_profile) config file add this line:

export MAVEN_OPTS="-Xmx2G"

To test, run mvn -v again and verify that it prints the Maven version, Maven home location, and Java version.

Upvotes: 0

Adriaan Koster
Adriaan Koster

Reputation: 16209

User @med_alpa had the right suggestion in my case (Windows):

I resolved the same issue on windows executing this command on windows command line : set MAVEN_OPTS=-Xmx1024M -XX:MaxPermSize=256M

So make sure to not put quotes around the value you set for MAVEN_OPTS

Upvotes: 4

Try using: -Xmx1024M

Note: 'M' instead 'm'

Upvotes: 0

sunil
sunil

Reputation: 1

alter jvm.config in .mvn directory ( it is in controller directory ). study mvn.sh that comes with maven. you will see MAVEN_OPTS setting in the script. try out java -version before altering. eg : java -Xmx512m -version now you know how to go about and make the changes.

/sunil

Upvotes: 0

Related Questions