I have a requirement to setup a cron on windows plateform. Cron application that I have built is purely in java and that internally uses workflow system using spring. It has main method which starts the workflow. Now, I want to start this application automatically at some time as set.
This can be done by:
1. Create a bat file for running main method. (jar filename.jar) jar has main class name entry in manifest file. Next set this bat file in windows scheduled task to schedule this at some time.
2. Create a web application. Create a servlet and call the same main class from servlet. Configure the servlet on server startup by adding an entry in web.xml load-on-startup tag. To reschedule again after some interval, use java timer task class or some tool like cron4j.
Could you please suggest which one is better approach. Is there any other approach to do this whole cron activuty. My java application basically does some database operation, refreshes some cache, create xml file, validates it and then send email.
Thanks for your reply. If I'm not wrong, with quartz I can write unix like expressions and can schedule classes but my main class needs to be started once by some mechanism.
What I'm looking for is some tool similar like crontab in unix which can directly start my java program (by invoking bat file). Further execution I can either use tool's cron feature or Cron4J/Quartz scheduling mechansim or simply by Java TimerThread and Timer task.
As Quartz or Cron4J both are purely in Java, so initially first call has to be from outside like windows scheduled task.
I have got few cron tool similar to crontab in unix like pycron, CRONw or 'AT' command on windows.
Have you came across any such/similar tool which is widely used on windows plateform to schedule jobs and can run as windows service.