Hi everyone,
I am creating a windows service in Java that writes data to an object. This object has to be accessible by another Java program. What is the best approach to take?
Thank you. Jack
Hi everyone,
I am creating a windows service in Java that writes data to an object. This object has to be accessible by another Java program. What is the best approach to take?
Thank you. Jack
Serialise the object to a File and read/write it with the other process! You can serialise it also to XML with frameworks like JAXB or XStream.
Another way is JMS, but it's hard to master.
I agree with the "put it in a file" approach, unless you elaborate on how the two java processes can "see" each other. Are they running at the same time? On the same machine? Etc. What data do you need to transfer?
If all applications and the service can write the data, you have a problem in determining which data is the correct (the one in application A or the service).
A simple approach to the "common datastore" problem could be a JNDI server which is included in most JEE servers like JBoss, where each configuration is told to read from the same JNDI server. I am unsure if clients can update information in JNDI but this is probably vendor specific.
Plain old RMI is what was used for what you need. Now newer alternatives such as WS are prefered, but maybe the first is enough to you.