I want to use JavaMail API and the JavaBeans Activation Framework to send emails in my program, but in order for it to function, JavaMail and JAF need to be installed on the system. I want to be able to run this program on any computer without having to install extra things to make it work. Is there any way to put the JavaMail and JAF jars in the program jar to make it run correctly without any previous installation?

有帮助吗?

解决方案

Today you're in luck. The answer is yes. All you need is to copy the required jars to your project. You need to add mail.jar and activation.jar files in your CLASSPATH. Mkyong have a complete example in JavaMail API – Sending email via Gmail SMTP example.

The required libraries also can download http://search.maven.org/

In another hand, if you need a dummy mail server for test, you can use Papercute from Codeplex. Unzip and run.

其他提示

If you want the user to download a single jar file that contains everything and just run that jar file, see One-JAR.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top