Zane Zane -4 years ago 153
Java Question

Writing a java program to send emails automatically on a timer

I would like to write a program that sends an automated email based on a timer that runs constantly. I would then like to somehow export this program from eclipse to a computer that does not run the ide, and run it constantly in the background. I have figured out the code to send emails through java, my question is more regarding how to export this project as an application (or something) that can be run on any computer without running it through the eclipse IDE.

Any help, or directions to a better a resource to learn from, would be greatly appreciated.

Answer Source

The simple (manual) approach to turning a Java program into something that runs outside Eclipse:

Obviously, you need at least a Java JRE installation on the execution platform to run java, and you should have configured your system (the $PATH or %PATH% environment variable) so that typing java runs the correct thing.

If you are using a build system like Maven, Ant, Gradle and so on, you can automate the step that generates the JAR. (In fact, you can automate the entire build ... and break your dependency on any IDE.)

I DO NOT recommend trying to create an "executable" for your Java application. For a start, executables cannot be run on any computer. They can only be run on computers running a specific operating system / OS family. A second problem is that you are effectively embedding a JRE in your application. That makes applying the latest Java security patches difficult.

As for the problems of keeping the application running "constantly" and sending emails at specific times, that is just Java programming.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download