Java 运行Maven时“无效的最大堆大小”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23787943/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"Invalid maximum heap size" when running Maven
提问by metaphizix
I'm having problems setting up maven. I'm using windows 7 64 bit with 4 GB of RAM.
我在设置 maven 时遇到问题。我正在使用带有 4 GB RAM 的 Windows 7 64 位。
I get this error when trying to run mvn:
尝试运行 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
回答by sunil
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.
更改 .mvn 目录中的 jvm.config(它在控制器目录中)。学习maven自带的mvn.sh。您将在脚本中看到 MAVEN_OPTS 设置。在更改之前尝试 java -version 。例如: java -Xmx512m -version 现在您知道如何进行更改。
/sunil
/苏尼尔
回答by David Hernández Martín
Try using: -Xmx1024M
尝试使用:-Xmx1024M
Note:'M' instead 'm'
注意:'M' 代替 'm'
回答by Adriaan Koster
User @med_alpa had the right suggestion in my case (Windows):
用户@med_alpa 在我的情况下有正确的建议(Windows):
I resolved the same issue on windows executing this command on windows command line : set MAVEN_OPTS=-Xmx1024M -XX:MaxPermSize=256M
我在 windows 命令行上执行此命令的 windows 上解决了同样的问题:set MAVEN_OPTS=-Xmx1024M -XX:MaxPermSize=256M
So make sure to not put quotes around the value you set for MAVEN_OPTS
所以请确保不要在您为 MAVEN_OPTS 设置的值周围加上引号