java 在 ant 任务中指定 jvm 参数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25039864/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 07:11:52  来源:igfitidea点击:

Specifying jvm arguments in ant tasks

javaantjvm-arguments

提问by user3875672

I am specifying jvm arguments since i was getting out of heap space exception so just to avoid that i was specifying the below parameters in my ant target that is as shown below..

我正在指定 jvm 参数,因为我已经超出了堆空间异常,所以只是为了避免我在我的 ant 目标中指定以下参数,如下所示..

  <junit
   printsummary="true"
   fork="yes"
   haltonfailure="false"
   failureproperty="junitsFailed"
   errorProperty="junitsFailed"
  >
   <jvmarg value=" -Xmx1024m -Duser.timezone=GMT0"/>
  </junit>

but below i am getting the below exception ..

但在下面我得到以下异常..

that is the invalid parameters are specified

回答by Chad Nouis

Use multiple <jvmarg>elements:

使用多个<jvmarg>元素:

<junit printsummary="true" fork="yes" haltonfailure="false" failureproperty="junitsFailed" errorProperty="junitsFailed">
    <jvmarg value="-Xmx1024m"/>
    <jvmarg value="-Duser.timezone=GMT0"/>
</junit>

回答by Aliaksei

You can set ANT_OPTS parameters. For example in Windows

您可以设置 ANT_OPTS 参数。例如在 Windows 中

SET ANT_OPTS=-Xmx1024m -XX:MaxPermSize=256m

or just use maxmemoryattribute of junitant task (http://ant.apache.org/manual/Tasks/junit.html):

或者只使用ant 任务的maxmemory属性junithttp://ant.apache.org/manual/Tasks/junit.html):

<junit maxmemory="1024m" ...