Search code examples
javajakarta-mail

java.lang.NoClassDefFoundError: com/sun/mail/util/LineInputStream for send mail through Java


Here my Exception LineInputStream

Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/mail/util/LineInputStream
        at javax.mail.Session.loadProvidersFromStream(Session.java:928)
        at javax.mail.Session.access$000(Session.java:174)
        at javax.mail.Session$1.load(Session.java:870)
        at javax.mail.Session.loadAllResources(Session.java:1130)
        at javax.mail.Session.loadProviders(Session.java:886)
        at javax.mail.Session.<init>(Session.java:210)
        at javax.mail.Session.getDefaultInstance(Session.java:299)
        at com.pack.utils.SendMail.sendMail(SendMail.java:67)
        at com.pack.utils.SendMail.sendMail(SendMail.java:34
)
    at com.pack.utils.SendMail.main(SendMail.java:133)

my dependency jars are java 1.6 , mailapi-1.4.4

i'm getting error this line

sessions[0] = Session.getDefaultInstance(props, null);  

Solution

  • This Solution helps me

    I added File permission in java.policy file and I changed Java6 to Java7

    permission java.io.FilePermission  "<<ALL FILES>>", "read"; };
    

    java.policy file available in C:\Program Files\Java\jre1.7.0\lib\security this path