Hi All, I have to write a Java program which sleeps for some particular time, wakes up and sends emails, then sleeps again. The program needs to run in the background. It needs to run on both windows and unix... Does anybody has any idea about how to do it ? Thanks!
The idea of running in the background is an pperating system concept, not an application one. For example, from a Unix shell, you could type something like: java MyProgram & to run the program in the background. That means the program runs, but leaves you free to type other stuff at the command prompt. You can also use: nohup java MyProgram & to ensure that your program doesn't exit, even if you close your shell. All output then goes to a file called nohup.out. As for your application, Thread.sleep(miliseconds) is the easiest way to pause for a set amount of time. If you want to wake up at a certain time, there are some timer classes that can probably help you.