• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Class not found : SharedByteArrayInputStream

 
Ranch Hand
Posts: 91
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to write a JAVA code for sending email using Java Mail API but I keep getting this class not found exception:



Following is my JAVA CODE:



I have included mailapi.jar, javamail-1.4.5.jar, activation.jar and smtp-1.4.4.jar and I can't seem to figure out why I am getting the exception.
 
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
SharedByteArrayInputStream is found in javax.mail.util
 
arushi tomar
Ranch Hand
Posts: 91
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Keith Lynn wrote:SharedByteArrayInputStream is found in javax.mail.util



I have also included javaxmail-api 1.4.5, still the same.
 
Keith Lynn
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You didn't import it
 
arushi tomar
Ranch Hand
Posts: 91
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Keith Lynn wrote:You didn't import it



I have included in the build path.
 
Keith Lynn
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But you didn't import the class in the source
 
arushi tomar
Ranch Hand
Posts: 91
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Keith Lynn wrote:But you didn't import the class in the source



How do I do that? I am using eclipse IDE.
 
Keith Lynn
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I misread your error. It looks like it is trying to use an instance of the class that isn't in javax.mail
 
arushi tomar
Ranch Hand
Posts: 91
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Keith Lynn wrote:I misread your error. It looks like it is trying to use an instance of the class that isn't in javax.mail



What may be the possible solution for this? I tried using different versions of the jar files but it didn't work.
 
Keith Lynn
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you included mail.jar?
 
arushi tomar
Ranch Hand
Posts: 91
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes I have.
 
Keith Lynn
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I used the following command line, but didn't get the error you got.

java -cp mail.jar;activation.jar;. JavaEmail
Exception in thread "main" javax.mail.AuthenticationFailedException
at javax.mail.Service.connect(Service.java:267)
at javax.mail.Service.connect(Service.java:137)
at JavaEmail.sendEmail(JavaEmail.java:65)
at JavaEmail.main(JavaEmail.java:24)

 
arushi tomar
Ranch Hand
Posts: 91
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was also getting this exception. I don't know how it has gone now. I am pretty sure once I resolve the Class not found exception, the next exception I will get is authentication.
 
Keith Lynn
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just tried it in Eclipse. I only included mail.jar and activation.jar and got the error I got before, but I didn't get the error you reported.
 
Bartender
Posts: 2910
150
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A java.lang.ClassNotFoundException usually happens when a jar is missing in your classpath. Can you please elaborate as to how you have "included" this jar in your path ?
Is this jar a part of your classpath during execution as well as compilation ?

Keith Lynn you would get a javax.mail.AuthenticationFailedException exception if you have not configured the smtp settings properly. Of course, it may not be the same as arushi's smtp settings.
Configurations includes the right port, using ssl, username/password, etc.

 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It looks like you are mixing incompatible versions of JAR files.

Make sure that the versions of javamail.jar, activation.jar and any other JAR files that you use are compatible with each other. For example, JavaMail version 1.4.5 will need some specific version of activation.jar and maybe other JARs. You have to find out which versions you need exactly and use those versions.
 
arushi tomar
Ranch Hand
Posts: 91
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

salvin francis wrote:


Included jars as : Build path> Libraries> Add external jars
 
arushi tomar
Ranch Hand
Posts: 91
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jesper de Jong wrote:



I will check the versions once. Hope that helps. Thanks
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic