Note that there are some explanatory texts on larger screens.

plurals
  1. POInvalid or corupt jarfile
    primarykey
    data
    text
    <p>I tried to create a jar file from a java project, which uses some external jars. I created a lib folder and put all the jars I need there.</p> <p>I run the project in eclipse by adding all the jars in the lib folder to the Build Path and it works ok.</p> <p>When I try to create the jar with ant from build.xml, it seems ok, no error is shown.</p> <p>When I try to run the jar, I get the message "Invalid or corupt jarfile".</p> <p>In build.xml: I define the path to use for compiling:</p> <pre><code>&lt;path id="project.classpath"&gt; &lt;fileset dir="${lib}"&gt; &lt;include name="**/*.jar"/&gt; &lt;/fileset&gt; &lt;/path&gt; </code></pre> <p>This is the target for the compilation:</p> <pre><code>&lt;target name="compile" depends="init" description="compile the source " &gt; &lt;!-- Compile the java code from ${src} into ${build} --&gt; &lt;javac srcdir="${src}" destdir="${build}"&gt; &lt;classpath refid="project.classpath"/&gt; &lt;/javac&gt; &lt;/target&gt; </code></pre> <p>And this is the target for making the jar file:</p> <pre><code>&lt;target name="dist" depends="compile" description="generate the distribution" &gt; &lt;mkdir dir="${dist}"/&gt; &lt;!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file --&gt; &lt;jar jarfile="${dist}/MyProject-${DSTAMP}.jar" basedir="${build}"&gt; &lt;manifest&gt; &lt;attribute name="Main-Class" value="${main}" /&gt; &lt;attribute name="Class-Path:" value="lib/**/*.*"/&gt; &lt;/manifest&gt; &lt;fileset dir="${src}" includes="images/**/*.*" /&gt; &lt;/jar&gt; &lt;echo file="${dist}/start.bat" message="java -jar MyProject-${DSTAMP}.jar" /&gt; &lt;/target&gt; </code></pre> <p>Can you please tell me what have I done wrong?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload