首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Exception >

java.lang.NoClassDefFoundError: javax mail Address

2014-01-26 
java.lang.NoClassDefFoundError: javax mail Address java.lang.Class.getDeclaredConstructors0(Native M

java.lang.NoClassDefFoundError: javax mail Address
java.lang.Class.getDeclaredConstructors0(Native Method)
java.lang.Class.privateGetDeclaredConstructors(Class.java:2328)
java.lang.Class.getConstructor0(Class.java:2640)
java.lang.Class.newInstance0(Class.java:321)
java.lang.Class.newInstance(Class.java:303)
org.apache.struts.util.RequestUtils.applicationInstance(RequestUtils.java:143)
org.apache.struts.action.RequestProcessor.processActionCreate(RequestProcessor.java:280)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:218)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

这是我的代码:

sendmailForm.getFrom(),//是谁发送的
sendmailForm.getStmphost()//邮件服务器
sendmailForm.getTo() //是发送给谁
sendmailForm.getContext(),//发送内容
sendmailForm.getTitle(),//发送标题
sendmailForm.getUser(),//用户名
sendmailForm.getPass()//密码


  try  {
  Properties  props  =  System.getProperties();
  props.put( "mail.smtp.host",sendmailForm.getStmphost());
  props.put( "mail.smtp.auth","true");

  Session  session  =  Session.getInstance(props,  null);
  MimeMessage  mimeMessage  =  new  MimeMessage(session);

  mimeMessage.setFrom(new InternetAddress(sendmailForm.getFrom()));

  mimeMessage.setRecipients(Message.RecipientType.TO,sendmailForm.getTo());
// iso-8859-1
  mimeMessage.setSubject(sendmailForm.getTitle(),"gb2312 ");
  mimeMessage.setText( sendmailForm.getContext(),"gb2312 ");
  mimeMessage.setHeader( "Content-Type ",  "text/html ");
  mimeMessage.setSentDate(new  Date());


  Transport  transport  =  session.getTransport( "smtp ");
  transport.connect(sendmailForm.getStmphost(),sendmailForm.getUser(),sendmailForm.getPass());
  transport.sendMessage(mimeMessage,  mimeMessage.getRecipients(Message.RecipientType.TO));
  //transport.send(mimeMessage);
  transport.close();
  System.out.println( "结束########################################## ");
  }
  catch  (Exception  e)  {
  e.printStackTrace();
  return mapping.findForward("error");
  }

------解决方法--------------------------------------------------------
mail.jar包没有导入
------解决方法--------------------------------------------------------
mail.jar activation.jar
好像是要两个包吧~
------解决方法--------------------------------------------------------
 

探讨
不是自带的吗?
我直接import javax.mail.*;
点出来的啊!


------解决方法--------------------------------------------------------
 

探讨
需要两个包,mail.jar activation.jar 。我前阵子也用了这个。

 

        

热点排行