当我们使用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了