This week's book giveaway is in the JavaFX forum.
We're giving away four copies of Introducing JavaFX 8 Programming and have Herbert Schildt on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Sending an AutoGenerated Email Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Sending an AutoGenerated Email" Watch "Sending an AutoGenerated Email" New topic

Sending an AutoGenerated Email

divya narayan

Joined: Sep 09, 2008
Posts: 3
I am trying to send an AutoGeneratedEmail from my javaapplication.
The jar files I use are mail.jar and activation.jar. But somehow both are not compatible and my code does not work.
My code is

And when I run without activation.jar it gives following error
Exception in thread "main" java.lang.NoClassDefFoundError: javax/activation/DataSource

Can someone tell me how to know the dependancy of mail.jar on activation.jar?

Thanks in advance

[edit]Add code tags. CR[/edit]
[ September 09, 2008: Message edited by: Campbell Ritchie ]
Rob Spoor

Joined: Oct 27, 2005
Posts: 20128

Is your classpath set up correctly? Because that class is in activation.jar

How To Ask Questions How To Answer Questions
divya narayan

Joined: Sep 09, 2008
Posts: 3
Yes, my classpath is set correctly.
Since the program is getting compiled, classpath has to be set properly.

Does the versions of jar files make any difference?
If so please suggest me which versions i can use, my jdk is jdk1.5.0_11 and jre is jre1.5.0_11.

Karup Mew
Ranch Hand

Joined: Aug 11, 2007
Posts: 40
check the version of Javamail Api and JavaBeans Activation Framework(JAF)which contains mail.jar and activation.jar respectively and must include both jar files in classpath otherwise use JAVA SE6 because it already included the activation.jar
divya narayan

Joined: Sep 09, 2008
Posts: 3
I have set classpath for both the jars.
The versions used are and respectively. Since my office uses this jdk version i cant update it to 6.

What else could be the reason?

Gamini Sirisena
Ranch Hand

Joined: Aug 05, 2008
Posts: 378
Can we take a look at your classpath?

And also the path where the jars are contained?

Also how are you executing this program? As a stand alone Java Program or as part of some container based application?
[ September 11, 2008: Message edited by: Gamini Sirisena ]
I agree. Here's the link:
subject: Sending an AutoGenerated Email
It's not a secret anymore!