views:

92

answers:

4

I have an application that needs to play some specifics audios(mp3) periodically. Let me give one example: Every Monday at 8:00am -> hello.mp3. How can I do that in Java?? I´m trying using Calendar, JodaTime, but I cant do it.

+1  A: 

What you want is a scheduled task. Timer class can provide this for you. Here is an example to get you started example

Pangea
+7  A: 

Depends, if you are using JEE, you can use EJB Timer. And there is always Quartz http://www.quartz-scheduler.org/

Julio Faerman
Quartz is very effective for this. I've seen it employed on a small scale and a large scale, and it's good for both and fairly easy to use.
glowcoder
A: 

What a Timer can help you to achieve is so minimum, Quartz Scheduler is a well-known (and easy-to-use) scheduler that accepts cron-like expression.

If you use Spring in your application, it has a scheduling module that can keep your Quartz code even cleaner.

yclian
A: 

You should use java.util.Timer to define schedules and java.util.TimerTask to define job. You can also use well-known Quartz Scheduler.

If you use Spring, you can use its scheduling service (it can be configured to use either Quartz Scheduler or java.util.Timer in its work).

If you run desktop App, the easiest way is to use java.util.Timer. For more complicated schedules use Quartz Scheduler.

IvanR