aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes Scheduling for a simple Java applciation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Scheduling for a simple Java applciation" Watch "Scheduling for a simple Java applciation" New topic
Author

Scheduling for a simple Java applciation

Madulika Reddy
Greenhorn

Joined: Mar 11, 2003
Posts: 10
All,
We have a java program which sends a email through smtp server. We want to schedule it once in a week.

Please advise on any options.

Also I heard J2EE schedulers which are used to schedule a task. Please suggest some.

Regards,
MReddy
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

If you need a Java solution I'd recommend Quartz. Other options would include a cron job if running in Linux or a scheduled task if running windows.


GenRocket - Experts at Building Test Data
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42277
    
  64
Quartz is a very good package, but it may be more than you need. Java comes with the built-in java.util.Timer and java.util.TimerTask classes, which have much less functionality, but may be sufficient for what you're doing.


Ping & DNS - my free Android networking tools app
Madulika Reddy
Greenhorn

Joined: Mar 11, 2003
Posts: 10
Hi Dittmer,
We are using WAS for the production. I heard that when using the J2EE app server and Timmer classes there will be some thread issues as both creates threads. Could you advise on this. Our application needs a report to sent out at fixed times. and one more advise, how much effort does it take?

Thanks
Madhulika
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42277
    
  64
I can't imagine why adding a thread of your own would create problems with threads the app server creates. It certainly should not, and -WAS being a serious and expensive piece of software- it better not. Using Timer and TimerTask is easy; I picked it up by simply studying the javadocs, although I don't remember the details now.

One thing to look out for is that threads can be scheduled at fixed times, or fixed time intervals. You need to set that when creating the thread. In the former case, the thread is run, e.g., every day at 3pm, no matter how long it takes to execute. In the latter case, it is run every, e.g., 24 hours after it last finished execution. So if it takes one hour to run, the second run will be started 25 hours after the first start, not 24 hours later (there are 24 hours between runs).
 
wood burning stoves
 
subject: Scheduling for a simple Java applciation