• Post Reply Bookmark Topic Watch Topic
  • New Topic

Cannot Find symbol "variable RecipientType" compilation error  RSS feed

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I have written a mail sending program both for console and servlet. While my console program is working well, servlet is giving following compilation error.


----------------------------------------------

Here are both programs:

Console: (Working well)
---------------------------------------------------

------------------------------

Servlet:

------------------------------


-------------------------------

Please help me.
 
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't give us information about differences in the compilation environment. Are you compiling one in an IDE and one on the command line, both on the command line, what? The error message is consistent with the server compilation being without the javamail library.

rc
 
Kumar Barun
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ralph Cook wrote:You don't give us information about differences in the compilation environment. Are you compiling one in an IDE and one on the command line, both on the command line, what? The error message is consistent with the server compilation being without the javamail library.

rc


Thank you for the response and sorry for what you didn't like.

I'm compiling both on command line. I have placed mail.jar file in tomcat's lib and it's set to CLASSPATH. When I comment out this

message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));

Comilation succeeds.
 
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kumar Barun wrote: . . . When I comment out this . . . Comilation succeeds.
No, when you comment that out you convert a compilation error which you know about to a logical error which you don’t know about. The compiler error is your friend (I know you don’t believe me, but it’s true). That is because compiler errors are found early in the process. Ignoring them might allow nastier errors into your code.

You have got two Message classes. That is the cause of the problem. You can tell from the error message because it give the name of the class as learn.Message.
  • Delete the import and use the fully-qualified name of the class in both places: message.addRecipient(javax.mail.Message.RecipientType.TO, new InternetAddress(to)); or . . .
  • Change the name of your own Message class.
  •  
    Kumar Barun
    Greenhorn
    Posts: 20
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Campbell Ritchie wrote:
    Kumar Barun wrote: . . . When I comment out this . . . Comilation succeeds.
    No, when you comment that out you convert a compilation error which you know about to a logical error which you don’t know about. The compiler error is your friend (I know you don’t believe me, but it’s true). That is because compiler errors are found early in the process. Ignoring them might allow nastier errors into your code.

    You have got two Message classes. That is the cause of the problem. You can tell from the error message because it give the name of the class as learn.Message.
  • Delete the import and use the fully-qualified name of the class in both places: message.addRecipient(javax.mail.Message.RecipientType.TO, new InternetAddress(to)); or . . .
  • Change the name of your own Message class.



  • You got me right, sir. I have a Message class and that was the conflicting point. It's resolved now.

    Thanks a lot for the help and friendly words. And your suggestion about Compiler Error is really great and valuable. Once again thank you.
     
    Campbell Ritchie
    Marshal
    Posts: 56600
    172
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Kumar Barun wrote:. . . . It's resolved now.

    Thanks a lot for the help and friendly words. . . .
    Well done and . . . “you’re welcome”
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!