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.
The simple (manual) approach to turning a Java program into something that runs outside Eclipse:
Create a runnable JAR following the instructions here: http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftasks%2Ftasks-37.htm.
If your application depends on library methods that are not part of the Java SE library, pay particular attention to the "select library handling strategy" step.
Run the application from the command line as follows:
$ java -jar yourapp.jar arguments ....
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.
Use Timer & TimerTask - e.g. http://www.mkyong.com/java/how-to-run-a-task-periodically-in-java/
Use a job scheduler. For instance Quartz has an easy to use API for running jobs on a fixed schedule: http://quartz-scheduler.org/documentation/quartz-2.x/tutorials/tutorial-lesson-06