This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff 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.