This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
The requirement is to have a java application that reads a file from a local directory and then send and email if the file has been found. Only this does not require any user intervention and only do the task at, say, every 7pm.
* I have already made the program that sends out mail and file reading.
Does anyone here have encountered this? Thanks so much for the help.
Thanks Mani. I have tried the Timer now Im facing another problem in my program that sends the email. It's giving me NoClassDefFoundError: com/sun/mail/util/SharedByteArrayInputStream. I have the j2ee.jar inside. And I dont know what could be the otherpossible problems. Thanks for the help.
Joined: Mar 11, 2002
Make sure that you have mail.jar and activation.jar files in your classpath.
If this application is needed a 24/7 support in a moderate enterprise, you need to check with your enterprise whether they have any mutiplatform schedulers already implemented.
If you use a timer a jvm should be running all the time. That means if the file extraction and mailing process takes five minutes you will be waisting resources for rest of the time. This is OK if you don't have other alternatives.
If you usea multiplatform scheduler you may write a batch script which runs your mailing and extraction program. You may configure the scheduler to trigger the batch script for particular time.
The point is regardless of running platform the scheduler should run 24 hours. So only a stable platform should be chosen for running scheduler. By using a timer in java you are making a custom scheduler.