aspose file tools*
The moose likes Beginning Java and the fly likes schedule method in timer class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "schedule method in timer class" Watch "schedule method in timer class" New topic
Author

schedule method in timer class

Joel Bijapurkar
Greenhorn

Joined: Aug 01, 2011
Posts: 20

Does the method :



schedule a task for execution only once or does it schedule the task for execution repeatedly on the specified date and time?
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3739
    
  16
What does the javadoc say ?
What happened when you tried it ?


Joanne
Joel Bijapurkar
Greenhorn

Joined: Aug 01, 2011
Posts: 20

The javadoc says that when we use the schedule(Timer task, Date time) function the specified task is scheduled for execution but does not explicitly mention if the task will be executed once or repeated. I tried it and it works as long as the NetBeans IDE is running.

When I close the IDE I get the following notification:

Exiting the IDE will close the following processes:
Process- Timer(run)

What should I do so that the program continues execution even after closing the IDE?

Here is the code I have created:



Thank you.
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

What should I do so that the program continues execution even after closing the IDE?

The Java process used to run your application is a sub-process of the IDE, so when you close the IDE all of its sub-processes are closed and your application stops. If you want your app to run independently of the IDE you should run the application from the command prompt rather than from the IDE.


Steve
Joel Bijapurkar
Greenhorn

Joined: Aug 01, 2011
Posts: 20

Thanks Steve. I found the solution. It is just as you said run the application from the command prompt. But in this case since I wanted to schedule the file for execution at a future time and date, I used a batch file. with the following code:



I then scheduled it using the windows scheduler and the following command:


and its working perfectly.
 
 
subject: schedule method in timer class