2

Have any one scheduled a java program to run at particular time of day? Does platform make any difference? I am using Windows.

Giorgi
  • 28,971
  • 12
  • 82
  • 118
yogsma
  • 9,106
  • 25
  • 86
  • 142

4 Answers4

3

You could of course let the Java program run constantly, and schedule the work to do there. I don't know if that's an option for you, but at least you get platform independence. For scheduling in Java there's different options like Quartz, java.util.Timer/java.util.TimerTask, etc. I guess there are so questions rating the different alternatives.

rlovtang
  • 4,730
  • 2
  • 26
  • 30
2

For unix-like platforms there is cron. This Stackoverflow question covers alternatives on Windows.

Community
  • 1
  • 1
rlovtang
  • 4,730
  • 2
  • 26
  • 30
  • How can I create executable from java file? "main" method is in different java file which calls this file. – yogsma Aug 04 '10 at 20:45
  • 1
    In your comment below, you say that your final target is Unix. cron is the standard job scheduler on Unix-like systems. Compiling your Java program is a whole separate question. You'll likely end up with a .jar that will need to be run. If an appropriate JVM is available on your Windows system, your program execution will be similar on both platforms. – DaveE Aug 04 '10 at 20:53
  • @DaveE - You are right. I will have jar file finally. I mentioned platform just for additional information. I know that confused with windows scheduling or unix scheduling. – yogsma Aug 04 '10 at 20:56
0

If you're on windows, and you have an executable, how about using the Windows Scheduler?

EDIT
Since you're not actually using windows: I don't know of any way to schedule something that still runs in debug (except, of course, compiling to an executable anyway).

I'm not familiar with Unix, but it looks like you'll need some kind of scheduler on Unix (if one isn't already installed) and do the same thing: essencially schedule the OS to call the executable- passing in whatever arguments are necessary.

AllenG
  • 7,946
  • 26
  • 38
  • Since I am testing it currently, I can't go for that option as my eventual production system is unix. So I want to make sure that the program runs as scheduled. – yogsma Aug 04 '10 at 20:36
  • 4
    then why do you even mention Windows in the question? – DaveE Aug 04 '10 at 20:48
0

You can use windows task schedule to schedule your program.

Giorgi
  • 28,971
  • 12
  • 82
  • 118