This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Java in General and the fly likes suggestion ways of setting up a cron on windows plateform Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "suggestion ways of setting up a cron on windows plateform" Watch "suggestion ways of setting up a cron on windows plateform" New topic
Author

suggestion ways of setting up a cron on windows plateform

nazzy khan
Ranch Hand

Joined: May 06, 2010
Posts: 39

Hi,

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.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10491
    
    9

You might want to check out quartz


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
nazzy khan
Ranch Hand

Joined: May 06, 2010
Posts: 39

Hi Maneesh,

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.

Thanks!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61456
    
  67

Windows Scheduler?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
nazzy khan
Ranch Hand

Joined: May 06, 2010
Posts: 39

Thanks.. I'm now using the same way

Regards,
Nazzy
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: suggestion ways of setting up a cron on windows plateform