Solved

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

Posted on 2009-07-01
5
330 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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

744 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now