JavaMail

I am trying to make a jar file that has class files for an email program. I have created the GUI for this already and I am using the code below to send the email. The program runs fine when I execute the main class. The problem comes up when I try to execute the .jar file. The error I receive is:

javax.mail.SendFailedException: Sending failed;

nested exception is:

class javax.mail.MessagingException: IOException while sending message;

nested exception is:

javax.activation.UnsupportedDataTypeException: no object DCH for MIME type text/plain; charset=us-ascii

Does anyone know how to run the email program in a .jar file? Thanks for the help.

Properties props = System.getProperties();

props.put("mail.smtp.host", host);

Session session = Session.getDefaultInstance(props, null);

// Define message

MimeMessage message = new MimeMessage(session);

message.setFrom(new InternetAddress(from));

message.addRecipients(Message.RecipientType.TO, to);

message.setSubject(subject);

// Fill the message

message.setText(body);

// Send the message

Transport.send(message);

[1181 byte] By [hubbdogga] at [2007-9-29 5:30:13]
# 1
You're saying when the classes are loose it works, and when they're in a jar it doesn't? Doesn't seem like that would cause that sort of error. Are the classes that work the exact same ones as the classes in the jar, or am I misunderstanding your problem statement?
nascha at 2007-7-14 18:35:20 > top of Java-index,Archived Forums,Java Programming...
# 2
No, that's the problem I am having. The classes are the same, the only thing is I had to add all the files in activation.jar and mail.jar because I kept getting NoClassDef for the classes in those jar files.
hubbdogga at 2007-7-14 18:35:20 > top of Java-index,Archived Forums,Java Programming...
# 3

I believe the FAQ for JavaMail specifically says to leave the jar files the way they are and not to unpack them. Your problem isn't with JavaMail, though, your problem is that you don't know how to specify the classpath for an executable jar file. You can find out how to do that by reading this part of the tutorial:

http://java.sun.com/docs/books/tutorial/jar/basics/manifest.html

DrClapa at 2007-7-14 18:35:20 > top of Java-index,Archived Forums,Java Programming...
# 4
Thanks for the help.
hubbdogga at 2007-7-14 18:35:20 > top of Java-index,Archived Forums,Java Programming...