5

I am trying to build a jar file and getting error Build Failed.

Problem creating jar: archive contains more than 65535 entries. (and the archive is probably corrupt but I could not delete it)

I am using Eclipse Neon Release 1 with JDK 1.8.0_101 and Ant version in eclipse is 1.9.6.

below is my ant build file :-

<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>

Varun J
  • 51
  • 1
  • 4

1 Answers1

19

Specify the zip64Mode argument on your jar task to say that you need to use the large 'zip64' format:

<jar destfile="${jar.dir}/${jar.name}" zip64Mode="always">
greg-449
  • 109,219
  • 232
  • 102
  • 145
  • Thanks greg-449. Jar is getting build now by adding zip64Mode="always". – Varun J Sep 19 '16 at 05:20
  • 1
    hi greg, I am making the exe using launch4j 3.9 from the created jar by adding the argument in jar zip64Mode as suggested by you. But now the exe is not working as it was working with earlier case. Is there any configuration needed for launch4j 3.9 to build exe from jar. I have already mentioned 1.8.0 in my launch4j configuration file. – Varun J Sep 20 '16 at 12:33
  • I don't know anything about launch4j – greg-449 Sep 20 '16 at 13:00
  • 2
    Is there any other configuration required for java 1.8 in the above ant.xml configuration file as my jar is not able to find .classfiles. – Varun J Sep 23 '16 at 05:40