开发者

Installing JavaMail using Eclipse JavaSE 1.6

开发者 https://www.devze.com 2022-12-30 01:38 出处:网络
Would someone please be able to explain开发者_如何学C to me how to properly install JavaMail and have it to execute in Eclipse please.

Would someone please be able to explain开发者_如何学C to me how to properly install JavaMail and have it to execute in Eclipse please.

I have been trying for the past few hours and I am completely lost as to why this is.

This is from trying to execute their demo projects msgsend.java and msgshow.java.

I either find an error message stating invalid protocol or could not connecto to SMTP host: localhost, port 25;


What I suggest.

  1. Open Eclipse
  2. Create a new Java project
  3. Create a new Java class which contains a main method (entry point)
  4. Create a folder "libs" inside which you put your JavaMail jar library and other external dependencies
  5. Right-click (from within eclipse) on the added JavaMail jar file and choose Build path and add to build path.
  6. Now you project should be ok in terms of dependencies and you can start coding your test logic within your main method or other classes you create
  7. Once coded, Run your project, by right-clicking on the class which represents your app's entry point and select Run and run as Java application

(That's all I can provide given the details in your question ;) )


If you're running the examples and it's using "localhost:25" as the server, you'll need to have an SMTP server running on the same machine.

If you don't have a local SMTP server, then try replacing "localhost" with the SMTP server hostname that your ISP provides you.


If you are getting an exception being thrown which is stating that it could not correct to an SMTP host (it may be helpful if you posted the exact error) that means that Javamail is correctly installed in your classpath but that it could not find the given SMTP host.

Keep in mind that by merely dropping Javamail into Eclipse will not automatically result in an SMTP server running on localhost (aka your own machine).

So, either set up an SMTP server on your machine or just use your ISP's server for test purposes.

I would suggest the later, but if you are interested in the former, you may want to check out: http://www.ericdaugherty.com/java/mailserver/

It includes an Eclipse plugin.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号