Solved

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

Posted on 2009-07-01
5
338 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to get all the API from website? 11 92
web services creation SOAP vs REST 5 42
Tomcat: Unable to run tomcat service. 2 20
Selenium docs api java index 3 20
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This video teaches viewers about errors in exception handling.

831 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