aspose file tools*
The moose likes Threads and Synchronization and the fly likes schedule a java program to run everyday at 6'0 clock Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "schedule a java program to run everyday at 6 Watch "schedule a java program to run everyday at 6 New topic
Author

schedule a java program to run everyday at 6'0 clock

amit kumar goyal
Greenhorn

Joined: Dec 07, 2006
Posts: 10
Hello,

I have to develop a java program which will run everyday at 6pm everyday. This program does some updation of the database. how to do this. Operating system is windows. it is a desktop application. Thanks.
Dave Robbins
Ranch Hand

Joined: Sep 16, 2003
Posts: 131
not sure why you would want to use threads for this
if you want to run the code at a certain time use the windows scheduler

http://www.iopus.com/guides/winscheduler.htm

use google to find more details

Dave
rangapriya addankitirumala
Greenhorn

Joined: Jan 07, 2008
Posts: 1
Use java.util.TimerTask
amit kumar goyal
Greenhorn

Joined: Dec 07, 2006
Posts: 10
Thanks everybody for the replies. I have done it using TimeTask.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16305
    
  21

Just to enumerate the common possibilities:

1. Use Unix/Linux cron and run the program under a batch script. Windows also has this ability, although the scheduler mechanism is different.

2. Set up a timer task thread (which you did).

3. Incorporate Quartz Scheduler and let it do cron-like functions. You'd normally only do this in the case where a long-running application (stand-alone or webapp) is present to house the quartz manager threads and the scheduling requirements are fairly complex.

Incidentally, one of the best ways to "hang" shutdown of a web application server is to run a scheduler inside a webapp. Until ALL threads - including the scheduler threads - are terminated, the appserver will probably not shut down. In the specific case of Tomcat, the appserver will definitely not shut down. You can remedy this by terminating the scheduler in a servlet's destroy() method,


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: schedule a java program to run everyday at 6'0 clock