i have a java code that writes data into a text file. I want to monitor this java code externally using another java file, and perform an action whenever the file is being updated. can someone help me on how that can be done, other than using RMI?
I don't think you need RMI for this if the code that writes or modifies the text file and the code that tracks the modification are in the same program. The could would logically be in different classes, but that's still O.K. I think separate Java Virtual Machines are only started for different programs, or different main methods.
I hope that helps.
Joined: Dec 15, 2004
Thanks for the help. However, I do have 2 seperate java files - one for updating the file, and the second for performing the operation on update. Please help me on this.
If they are two classes within the same running JVM you can look into the Observer or Publish-Subscribe pattern. The object that wants to know about changes registers itself with the object that makes changes, or alternatively with an intermediary. Look for "Publish Subscribe" Messaging Patterns and see if that makes sense.
If you have two processes running on the same machine things are harder. People often make one process periodically check a folder to see if anything has changed recently. I'm hoping this is not your situation.
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