File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes schedule job in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "schedule job in java" Watch "schedule job in java" New topic

schedule job in java

maheshk lala

Joined: Jul 08, 2005
Posts: 1
Hello Friends ,

I want a java schedule program that runs every hour . It should search for in a directory for the latest files received in a hour and should read those files for every one hour . its a very urgent and your help is highly appreciated .
Using java.util.Timer etc.

Thanks for your help in advance .

Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
I guess Threads should work.
Or google for schedulers and run the job each and every hour with the help of scheduler.
[ July 08, 2005: Message edited by: Srinivasa Raghavan ]

Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
What operating system are you running? If you are running Linux, usually you use cron to schedule jobs like this. You can write your program in Java without any of the scheduling logic. The cron daemon will run your program at the specified times. Check the man pages for more details or visit our Linux/Unix forum.

However, I'm willing to bet you are using Windows instead. As Srinivasa mentioned above, you can probably google for a scheduler for Windows that works similarly to cron.


Java API Documentation
The Java Tutorial
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Or you can make your java program run forever and schedule the directory scans within the program. See Timer.

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Tim West
Ranch Hand

Joined: Mar 15, 2004
Posts: 539
If you want a pure Java implementation, then AFAIK your best bet is the Quartz scheduler. Depending on your requirements, this may be better than using Cron or a similar platform-specific method.

Quartz has all sorts of features for handling clusters of applications too. I'm not familiar with it beyond the basics, though.

[Edit - oops, I see the requirement is 'program that runs every hour', not
'job within program that runs every hour'. Still, I'll leave this post as it stands.]

[ July 08, 2005: Message edited by: Tim West ]
I agree. Here's the link:
subject: schedule job in java
It's not a secret anymore!