I have written a Java program which retrieves Google data till present date using Google Analytic API and export it as CSV file. I want this program to run daily so that data in the CSV file will be up to date. How can I achieve this?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You can use the Windows Task Scheduler (see tutorial) to start any program; for Java, you will probably want to create a batch file to run your Java program, then use the Scheduler to run the batch file.
You can also use an executable JAR.
You may need to specify the start directory - see this thread.
回答2:
Schedule Via Java
Use a ScheduledExecutorService
and the method scheduleAtFixedRate
with a TimeUnit
of Day. Your program will wait a day and then do what it has to do.
Of course your computer has to be on. If that is an issue, it might be better do something like this using Google App Engine.
回答3:
Have a look at Windows Task Scheduler. Task scheduling can be found under all programs -> accessories -> system tools -> scheduled tasks.