Ant编译失败Java heap space

时间:2024-03-31 22:34:01
  •   Eclipse Ant编译出现内存不足,常见错误,提示如下:
Buildfile: F:\workspace\javaee\myapp\build.xml
init:
prepare:
     [echo] Preparing target directory 'F:\workspace\javaee\myapp/build/psmis'
    [mkdir] Created dir: F:\workspace\javaee\myapp\build\psmis
    [mkdir] Created dir: F:\workspace\javaee\myapp\build\psmis\WEB-INF
    [mkdir] Created dir: F:\workspace\javaee\myapp\dist\webapps
hibernatedoclet:
[hibernatedoclet] (XDocletMain.start                   48  ) Running <hibernate/>
[hibernatedoclet] Java heap space
[hibernatedoclet] ParameterImpl instances:   20
[hibernatedoclet] MethodImpl instances:      6849
[hibernatedoclet] ConstructorImpl instances: 299
[hibernatedoclet] SimpleNode instances:      0
[hibernatedoclet] SourceClass instances:     406
[hibernatedoclet] XDoc instances:            0
[hibernatedoclet] DefaultXTag instances:     0
[hibernatedoclet] BinaryClass instances:     70
[hibernatedoclet] UnknownClass instances:    67
[hibernatedoclet] Total memory:    63
[hibernatedoclet] Free memory:    0
[hibernatedoclet] Try to increase heap size. Can be done by defining ANT_OPTS=-Xmx640m
[hibernatedoclet] See the JDK tooldocs.

BUILD FAILED
F:\workspace\javaee\myapp\build.xml:237: Java heap space

Total time: 16 seconds

 

 

 

  •  根据提示信息,增加堆空间大小,修改Eclipse VM参数:-Xmx640m;修改路径:Window-->Preferences-->Java-->Installed JREs-->选中的JRE-->Edit...

    Ant编译失败Java heap space
     
      
  •  如果要在命令行中执行Ant,则需要在操作系统增加环境变量ANT_OPTS=-Xmx640m
    F:\workspace\javaee\myapp>set ANT_OPTS=-Xmx640m
     
    Ant编译失败Java heap space