创建jar存档时出错包含超过65535个条目

时间:2016-09-16 05:47:13

标签: java eclipse ant

我正在尝试构建一个jar文件并收到错误Build Failed。

创建jar时出现问题:存档包含超过65535个条目。 (存档可能已损坏,但我无法将其删除)

我正在使用Eclipse Neon Release 1和JDK 1.8.0_101,而eclipse中的Ant版本是1.9.6。

下面是我的ant构建文件: -

<property name="jar.name" value="ABC.jar" />
<property name="source.root" value="src" />
<property name="class.root" value="bin" />
<property name="lib.dir" value="lib" />
<property name="jar.dir" value="C:\D\ABC-Exe" />
<property name="Main-Class" value="com.abc.xxx.main.ABCEval" />
<property name="conf.pkj" value="com/abc/xxx/business/configurations" />
<property name="img.pkj" value="com/abc/xxx/business/images" />

<path id="project.class.path">
    <pathelement location="${class.root}" />
    <fileset dir="${lib.dir}">
        <include name="*.jar" />
    </fileset>
</path>

<target name="clean" description="cleans up build structures">
    <delete dir="${class.root}" />
    <delete file="${jar.dir}/${jar.name}" />
</target>

<target name="prepare" description="sets up build structures">
    <mkdir dir="${class.root}" />
</target>

<target name="compile" depends="prepare" description="Compiles all java classes">
    <javac srcdir="${source.root}" destdir="${class.root}" debug="on" optimize="off" deprecation="on" source="1.8" target="1.8" includeantruntime = "false">

        <classpath refid="project.class.path" />
    </javac>

    <mkdir dir="${class.root}/${conf.pkj}" />
    <mkdir dir="${class.root}/${imwg.pkj}" />

    <copy todir="${class.root}/${conf.pkj}">
        <fileset dir="${source.root}/${conf.pkj}" />
    </copy>

    <copy todir="${class.root}/${img.pkj}">
        <fileset dir="${source.root}/${img.pkj}" />
    </copy>

</target>

<target name="jar" depends="compile"> 

    <delete file="${jar.dir}/${jar.name}" quiet="true" failonerror="false" />

    <jar destfile="${jar.dir}/${jar.name}">

        <fileset dir="${class.root}" includes="**/*.*" />
        <fileset dir="${source.root}" includes="**/api/*.java,**/api/vo/*.java"/>

        <zipgroupfileset dir="${lib.dir}" />


        <manifest>
            <attribute name="Main-Class" value="${Main-Class}" />
            <attribute name="Class-Path" value="." />
        </manifest>

    </jar>


</target>


<target name="run">
    <java fork="true" classname="${Main-Class}">
        <classpath>
            <path location="./${jar.name}" />
        </classpath>
    </java>
</target>

1 个答案:

答案 0 :(得分:12)

zip64Mode任务中指定jar参数,说明您需要使用大型'zip64'格式:

<jar destfile="${jar.dir}/${jar.name}" zip64Mode="always">