使用myeclipse8.5 1)發郵件提示 javax.mail.NoSuchProviderException: smtp。 使用oracle最新的javamail.jar包替換,加載到build path,下載地址 http://www.oracle.com/technetwork/java/index-138643.html ; 又報錯: 2)Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/mail/util/LineInputStream。 緣由:mail.jar與javaee.jar產生衝突。解決辦法:找到myeclipse8.5目錄下 (Genuitec\Common\plugins\com.genuitec.eclipse.j2eedt.core_8.5.0.me201003231033\data\libraryset\EE_5),使用壓縮文件方式打開javaee.jar找到mail與activation文件夾,而且直接刪除就OK,問題解決。 測試發信又報錯 3)Exception in thread "main" java.lang.NoClassDefFoundError: javax/activation/DataSource。 缺乏 javax.activation 包下的一些類;回頭看mail.jar的下載頁面,就是上面的鏈接,上面有以下說明: Note: Unless you're using Java SE 6, you will also need the JavaBeans Activation Framework (JAF) extension that provides the javax.activation package. We suggest you use version 1.1.1 of JAF, the latest release. JAF is included with Java SE 6. 緣由找到,個人項目裏jre-system-library用的是javase1.5, 解決辦法,1)把項目裏的1.5,更換到javase1.6. 或者 2)不用1.6的話就本身下個Activation.jar包。下載地址: http://www.oracle.com/technetwork/java/javase/jaf-136260.html 估計都用1.6了吧。 最後測試成功. 1)若更換至jdk1.6的jre 一些com.sun.XXX的包不能用的話,是myeclipse的設置問題,使用下面設置: window->Preferences->java->Complicer->Errors/Warnings面板中 Deprecated and restricted API選項中的Forbidden references(access rules)選爲Warning就能夠編譯經過了