Re: Eclipse and creating JAR general guidance.
From: zoopy (zoopy_at_hates.spam)
Date: Fri, 06 Aug 2004 23:47:08 +0200
On 6-8-2004 20:02, vivienne wykes wrote:
> Hi All,
> I have just started using Eclipse and I am working through the O'Reily
> Eclipse book.
> I have a few basic questions which I would like some guidance.
> My understanding of executable JAR files is that they contain the class
> files required and a Manifest file which would define the main class. In
> windows to run the program we would double click the JAR.
> A chapter in the book describes the basic use of ANT which using an XML
> script initializes , compiles then JARs my project.
> When I double click the JAR I get an error message ... Failed to load main
> class manifest attribute....
> When I look at the manifest file Main Class is not defined . I would have
> thought this could be defined by Eclipse/ANT
> Any one have an Idea as to how I could define the main class or if the
> manifest could be altered afterwards..then re-Jarred?
> I am new to Eclipse ANT and XML so you can imagine my learning curve at
> Much appreciated
> Jim Ascroft
To specify the main class of a jar created with Ant, you have to add a <manifest> parameter to the
<jar> task. The <manifest> tag must contain a nested <attribute> tag that defines the main class.
<target name="createjar" depends="compile,init">
May you already know, but Eclipse is also capable of creating a jar (with a main class attribute):
menu File/Export, select "JAR file" and follow the wizard (default values are in most circumstances
OK; the last step allows you to specify the main class; save the description of the jar to a
.jarsdesc file, so you can right-click to have the jar re-created).