wood burning stoves 2.0*
The moose likes Threads and Synchronization and the fly likes running java application in background Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "running java application in background" Watch "running java application in background" New topic

running java application in background

Srikrishna DhumalRao

Joined: Oct 05, 2004
Posts: 17
I have to develop a java application which runs in the backround continuosly monitors the database and sends mail to the concerned persons depending on the work status(pending/testing/etc).Kindly let me know how to achieve it.

Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

What OS?
What do you have so far?

Srikrishna DhumalRao

Joined: Oct 05, 2004
Posts: 17
I am working on a Win2000 OS . Actually it is a defect tracking tool, I have to design an escalation module , which has to generarte mails to the upper hirerachy depending on the priority,severity and maximum allotted time for the defect.I wanted this to run continuosly communicating with the database and send mails.I completed mail generator program which runs when ever I run the program , but I wanted it to run continously in the background.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
You just need a loop that will run forever ... or until you tell it to stop. I'd put it in the run method of a class that implements Runnable.

You might need to find a way to interrupt the wait on the runnable to make it exit right away.

Does that give you enough to start? If you can run this as a service under Windows you won't need the readline and stop ... you can just stop the service.

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Mr. C Lamont Gilbert
Ranch Hand

Joined: Oct 05, 2001
Posts: 1170

be sure to use sleep and wait, etc. so that the loop only executes code when there is something for it to do.
Srikrishna DhumalRao

Joined: Oct 05, 2004
Posts: 17
Thanks I got it
I agree. Here's the link: http://aspose.com/file-tools
subject: running java application in background
Similar Threads
main method
Session Time out
Getting database connection failed
Not serializable Exception or No Data to read from socket
Print pdf file without opening.