Solved

need java code to run a java program  daily at 4 oclock starting from tomorrow

Posted on 2009-07-01
5
339 Views
Last Modified: 2013-11-23
need a java code that runs a program which takes some files as input and generates an output file everyday at 4.clock starting from tomorow
import java.util.Calendar;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
 
public class ReadFileAndUpdateDb extends TimerTask {
 
  public void run() {
    //TODO  Code To  Read File And Update Db 
 }
 
}
 
class MainApplication {
 
  public static void main(String[] args) {
    Timer timer  new Timer();
    Calendar date = Calendar.getInstance();
    date.set(
      Calendar.DAY_OF_WEEK,
      Calendar.SUNDAY
    );
    date.set(Calendar.HOUR, 0);
    date.set(Calendar.MINUTE, 0);
    date.set(Calendar.SECOND, 0);
    date.set(Calendar.MILLISECOND, 0);
    // Schedule to run every Sunday in midnight
    timer.schedule(
      new ReadFileAndUpdateDb (),
      date.getTime(),
      1000 * 60 * 60 * 24 * 7
    );
  }
}

Open in new window

0
Comment
Question by:supportpro
  • 2
5 Comments
 
LVL 36

Expert Comment

by:Loganathan Natarajan
ID: 24752727
You can consider to put it  CRON or window scheduler . what is your OS?
0
 

Author Comment

by:supportpro
ID: 24753113
Windows  XP.But i prefer it to be in java code
0
 
LVL 23

Expert Comment

by:Kamaraj Subramanian
ID: 24753319
schedule a task in windows xp

How to schedule ?
http://support.microsoft.com/kb/308569

and set the time as 4:00
0
 
LVL 23

Accepted Solution

by:
Kamaraj Subramanian earned 500 total points
ID: 24753330
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
servlet doXXX methods 3 62
reverse digits of a number using for loop 5 52
how to install java on RHEL image on EC2 4 40
SequenceInputStream example 3 19
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question