Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 360
  • Last Modified:

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

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
supportpro
Asked:
supportpro
  • 2
1 Solution
 
Loganathan NatarajanLAMP DeveloperCommented:
You can consider to put it  CRON or window scheduler . what is your OS?
0
 
supportproAuthor Commented:
Windows  XP.But i prefer it to be in java code
0
 
Kamaraj SubramanianApplication Support AnalystCommented:
schedule a task in windows xp

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

and set the time as 4:00
0
 
Kamaraj SubramanianApplication Support AnalystCommented:
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now