Originally posted by lakshmi Sailaja:
I need to execute a piece of java code once a week at a specific time. How do I do that ? Can anyone please tell me ?
Do you need to execute the piece of code from within a Java application? Or do you need to execute a Java application from your OS?
If it is the latter (execute from OS), you can use NT's at-scheduler (type "help at" from the NT command prompt). If you are running UNIX, I think you can use either "at" or "cron" (type "man at" or "man cron" for more details). The argument to at or cron would be "java MyClass myarg1 myarg2".
If the problem is the former (execute from within Java app), I guess you could have some sort of
thread that woke up at specified intervals, executed some code, then went back to sleep. This isn't guaranteed to be very precise, and I'm not entirely sure that it would work. (I am not a threading expert by any means.)
My recommendation would be to use at or cron, and restructure your classes so that there's a main() in a class that you can run from at or cron.
--
Susan