• Post Reply Bookmark Topic Watch Topic
  • New Topic

How can I create a background process  RSS feed

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The situation I have at hand is this:
There is a file on the computer and I want to monitor this file using a java program that runs in the background. As soon as a new line is added to this file, the java program monitoring the file performs an action. Any suggestions as to how this can be achieved?
How can I possibly make a java program run in the background. Im working on windows and am using jdk 1.6.
Thanks in advance
 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You simply write the java program. If you do not code a GUI and have your program never exit, it will run in the background...

When you check your file for changes, do not forget to always close it when you're done, as other programs might not be able to modify it when another application holds the pointer to it.
 
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Several libraries are available for running Java code as a Windows service; "Java Service Wrapper" is a popular one.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!