ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Conor MacNeill" <co...@cortexebusiness.com.au>
Subject RE: Failed to load Main-Class manifest from foo.jar
Date Mon, 04 Mar 2002 02:04:27 GMT
Ray,

You need to construct the manifest yourself. In general, Ant can't know
which class is to be the main class. You need to specify this in the
manifest using the Main-Class header. Here is an example where you specify
the Main-Class in the build file

    <jar basedir="${bin.dir}/start" jarfile="${distlib.dir}/start.jar">
      <manifest>
        <attribute name="Main-Class" value="org.apache.ant.start.Main"/>
      </manifest>
    </jar>

Alternatively you can create a manifest file and use that in the <jar> task.
Checkout the documentation

http://jakarta.apache.org/ant/manual/CoreTasks/jar.html

Conor

> -----Original Message-----
> From: Ray Tayek [mailto:rtayek@attbi.com]
> Sent: Monday, 4 March 2002 12:57 PM
> To: ant-user@jakarta.apache.org
> Subject: Failed to load Main-Class manifest from foo.jar
>
>
> hi, i used the following sample ant script (copied from the doc)
> to build a
> jar. but when i try to run it using java -jar foo.jar, i get the above
> error message. i looked at the jar and the manifest has no files
> in it. is
> this a bug in ant? or do i need to invoke the jar in some
> different manner?
> or build the manifest myself? i am using ant 1.4.1 with j2sdk1.4.0
>
> thanks
>
> <project name="MyProject" default="dist" basedir=".">
>
>    <!-- set global properties for this build -->
>    <property name="src" value="."/>
>    <property name="build" value="build"/>
>    <property name="dist"  value="dist"/>
>
>    <target name="init">
>      <!-- Create the time stamp -->
>      <tstamp/>
>      <!-- Create the build directory structure used by compile -->
>      <mkdir dir="${build}"/>
>    </target>
>
>    <target name="compile" depends="init">
>      <!-- Compile the java code from ${src} into ${build} -->
>      <javac srcdir="${src}" destdir="${build}"/>
>    </target>
>
>    <target name="dist" depends="compile">
>      <!-- Create the distribution directory -->
>      <mkdir dir="${dist}/lib"/>
>
>      <!-- Put everything in ${build} into the
> MyProject-${DSTAMP}.jar file -->
>      <jar jarfile="${dist}/lib/MyProject-${DSTAMP}.jar"
> basedir="${build}"/>
>    </target>
>
>    <target name="clean">
>      <!-- Delete the ${build} and ${dist} directory trees -->
>      <delete dir="${build}"/>
>      <delete dir="${dist}"/>
>    </target>
> </project>
>
> ---
> ray tayek http://home.earthlink.net/~rtayek/
> actively seeking telecommuting work
> orange county java users group http://www.ocjug.org/
> hate spam? http://samspade.org/ssw/
>
>
> --
> To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message