"Invalid maximum heap size" when running Maven

12,911

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

Share:
12,911
metaphizix
Author by

metaphizix

Updated on June 04, 2022

Comments

  • metaphizix
    metaphizix almost 2 years

    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
    
  • Maciej Jureczko
    Maciej Jureczko over 6 years
    Please add some explanation what is the difference and why should the OP do that.