·软件知识库 ·模板素材库
注册 | 登录

您所在的位置: INDEX > j2se > ant编译java文件报内存溢出的问题

ant编译java文件报内存溢出的问题

许杰 Sun Jul 05 12:01:51 CST 2015 字号:

当我们使用ant来编译java文件的时候,文件过多会报以下错误:

compile:

    [javac] Compiling 730 source files to d:\java\Tomcat\work\Catalina\localhost\kmss_hr

    [javac] The system is out of resources.

    [javac] Consult the following stack trace for details.

    [javac] java.lang.OutOfMemoryError: Java heap space

    [javac] Compile failed; see the compiler error output for details.

解决办法是在build.xml中的javac命令中加参数,增大编译时候的内存(红色部分是加的参数):

 <target name="compile">

  <mkdir dir="${webapp.path}/WEB-INF/classes" />

  <mkdir dir="${webapp.path}/WEB-INF/lib" />

  <javac

   destdir="${jsp.destdir}"

   encoding="UTF-8"

   optimize="off"

   debug="on"

   fork="true"

   memoryMaximumSize="512M"

   failonerror="false"

   srcdir="${webapp.path}/WEB-INF/src"

   excludes="**/*.smap">

   <classpath>

    <pathelement location="${webapp.path}/WEB-INF/classes" />

    <fileset dir="${webapp.path}/WEB-INF/lib">

     <include name="*.jar" />

    </fileset>

    <pathelement location="${tomcat.home}/common/classes" />

    <fileset dir="${tomcat.home}/common/lib">

     <include name="*.jar" />

    </fileset>

    <pathelement location="${tomcat.home}/shared/classes" />

    <fileset dir="${tomcat.home}/shared/lib">

     <include name="*.jar" />

    </fileset>

   </classpath>

   <include name="**" />

   <exclude name="taglib/**" />

  </javac>

 </target>

修改完成后,再次编译就OK了



『相关搜索』
版本信息:kms v1.3 鄂ICP备2023004815号-1 51LA统计