how to export mail.jar ?

Hi to everybody!

i'm writing a desktop application that needs to send e-mail (i'm using NetBeans do develop it). These are the steps i've done:

* I've downloaded the javamail-1.4 and jaf-1.1 (activation) libraries and i've added them into my project using "Libraries -> AddLibrary" as i've always done. And everything works.

* I've written my code (i.e. an emailSender class) and compiled it. And everything works.

* I run the application from NetBeans. And everything works (the email are sent).

* I've added into build.xml the code

<target name="-post-jar">

<jar update="true" destfile="${dist.jar}" manifest="manifest.mf">

<zipfileset src="${libs.swing-layout.classpath}"/>

<zipfileset src="C:\\Programs\\Java\\jaf-1.1\\activation.jar"/>

<zipfileset src="C:\\Programs\\Java\\javamail-1.4\\mail.jar"/>

</jar>

</target>

to export the myproject.jar file as an executable on other systems but when i double-click on the jar i see the error:

Could not find the main class. Program will exit

* Then i've removed the two zipfileset tags and left the target tag as

<target name="-post-jar">

<jar update="true" destfile="${dist.jar}" manifest="manifest.mf">

<zipfileset src="${libs.swing-layout.classpath}"/>

</jar>

</target>

Thus the application still run correctly if loaded from NetBeans but if loaded by double-clicking the jar file (after a rebuild of the project) it throws the following exception:

class java.lang.NoClassDefFoundError

javax/mail/MessagingException

Of course id does not fount the definition of MessagingException.

* I've tryed to add the mail.jar, using the jar command line, into myproject.jar but i haven't solved the problem.

So, how could i add into myproject.jar the mail library without having the NoClassDefFoundError exception? I think the error appear only when exporting into the jar the mail api. But the manifest.mf file always contains

Manifest-Version: 1.0

Ant-Version: Apache Ant 1.6.5

Created-By: 1.5.0_06-b05 (Sun Microsystems Inc.)

Main-Class: Main.Main

and it looks correct.

Thank you in advance !!

alevincio

[2679 byte] By [alevincioa] at [2007-10-3 3:26:03]
# 1

You don't want to include mail.jar in your jar file, and you don't

even want to include the classes in mail.jar in your jar file.

What you want to do is to set up your jar file to reference mail.jar

and activation.jar, e.g., by including a ths in your manifest file:

Class-Path: mail.jar activation.jar

Then make sure that mail.jar and activation.jar are in the same

directory as your jar file.

bshannona at 2007-7-14 21:19:10 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2
Rally thanks .. it works!!I have never really practised with the manifest file..i've added the class path and it works wothout any kind of errors.Ciao!!
alevincioa at 2007-7-14 21:19:11 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3

i have developed the sending email using swings. now i want to wrap the things in a single jar or an exe file adding those mail.jar and activation.jar files also

please any one help me how to do it. please .. i have to give an demo in the college. i am trying but not working

please....

vijaykumarlra at 2007-7-14 21:19:11 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 4
It's difficult to put everything into a single jar file or exe file.Instead, follow the suggestions in this thread and distributeyour application as a collection of files. Wrap it all in a zipfile for distribution if you want.
bshannona at 2007-7-14 21:19:11 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...