当前位置: 技术问答>java相关
小弟才學 JavaMail 安書上的例子寫了下面的代碼 編譯通過但是 運行不了 幫忙看看!!!!
来源: 互联网 发布时间:2015-02-24
本文导语: import javax.mail.*; import javax.mail.internet.*; import java.util.*; public class Assimilator{ public static void main(String args[]){ try{ Properties Props=new Properties(); Props.put("mail.host","163.net"); Session...
import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
public class Assimilator{
public static void main(String args[]){
try{
Properties Props=new Properties();
Props.put("mail.host","163.net");
Session mailConnection=Session.getInstance(Props,null);
System.out.println("here");
Message msg=new MimeMessage(mailConnection);
Address bill=new InternetAddress("god@micorosoft.com");
Address elliotte=new InternetAddress("liuxing23@163.net");
msg.setContent("resis is full","text/plain");
msg.setFrom(bill);
msg.setRecipient(Message.RecipientType.TO,elliotte);
msg.setSubject("You Well");
Transport.send(msg);
}catch (Exception e){
e.printStackTrace();
}
}
}
錯誤提示如下:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/activation/DataSource
at Assimilator.main(Assimilator.java:17)
import javax.mail.internet.*;
import java.util.*;
public class Assimilator{
public static void main(String args[]){
try{
Properties Props=new Properties();
Props.put("mail.host","163.net");
Session mailConnection=Session.getInstance(Props,null);
System.out.println("here");
Message msg=new MimeMessage(mailConnection);
Address bill=new InternetAddress("god@micorosoft.com");
Address elliotte=new InternetAddress("liuxing23@163.net");
msg.setContent("resis is full","text/plain");
msg.setFrom(bill);
msg.setRecipient(Message.RecipientType.TO,elliotte);
msg.setSubject("You Well");
Transport.send(msg);
}catch (Exception e){
e.printStackTrace();
}
}
}
錯誤提示如下:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/activation/DataSource
at Assimilator.main(Assimilator.java:17)
|
http://java.sun.com/beans/glasgow/jaf.html
下载它,加入classpath里
下载它,加入classpath里
|
import javax.activation.*;
|
我也遇到过这个问题的。可能是你的路径没有设置好。
set classpath=全路径名称
注意最后不要加“”。
试试看,行不行。
set classpath=全路径名称
注意最后不要加“”。
试试看,行不行。