hello, I'm using eclipse platform to try to transfer file using Java mail API, but facing the following exception
java.lang.NoClassDefFoundError: com/sun/mail/util/SharedByteArrayInputStream
I know this is a common problem, but i've tried all possible measures to get rid of this exception
here's what i tried
* I downloaded javamail-1.4.3 from sun site, and copied mail.jar and activation.jar to my classpath java/jre6/lib/ext
* i noticed there's no SharedByteArrayInputStream in mail/util, so i modified my jar file by copying this missing class from javax/mail/util to com/sun/mail/util/, and added it to classpath again, but the error persists.
* i also imported archive(both .jar files) into my project, but no use.
import javax.mail.*;
import javax.mail.event.TransportListener;
import javax.mail.event.TransportEvent;
import javax.mail.internet.*;
import java.util.Properties;
import javax.activation.*;
class test5 {
private String mailHost="smtp.gmail.com";
private String body;
private String myFile="C:\\sample_text.docx";
private Properties props;
private Session mailSession;
private MimeMessage message;
private InternetAddress sender;
private Multipart mailBody;
private MimeBodyPart mainBody;
private MimeBodyPart mimeAttach;
private DataSource fds;
void fun()
{
//Creating a Session
props=new Properties();
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.host", mailHost);
props.put("mail.smtp.port", "25");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable","true");
mailSession=Session.getDefaultInstance(props, new MyAuthenticator());
message=new MimeMessage(mailSession);
mailBody=new MimeMultipart();
}
public static void main(String args[])
{
test5 obj = new test5();
obj.fun();
}
}
class MyAuthenticator extends Authenticator
{
MyAuthenticator()
{
super();
}
protected PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication("myusername", "mypassword");
}
}
how should i resolve this problem????
Please help.