Solved

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

Posted on 2009-07-01
5
346 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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
login jsp example 24 105
Eclipse Help Java EE 5,6,7 Documentation, why not Java EE 8 8 71
jsp error 6 72
American Express @Work site and Java 4 97
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
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…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

752 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