Search code examples
javarmi

Java RMI and remote file access


I'm just starting to learn Java's RMI, and believe I understand the process, client sends method requests and params, server does computation and sends return result back.

However does the server perform everything within the method locally?

Specifically, if a file is read in the method, am I correct in thinking this is performed by the server?

If this is the case is there any way for the method to specifically access resources from the client (such as the client's System.out?)


Solution

    1. If by locally, you mean on the server (virtual) machine, the answer is yes.
    2. Yes.
    3. No, only values explicitly passed as arguments to the remote method are accessible. And you can only pass objects which are Serializable, and streams typically aren't.

    Having said that, a client can also act as a server, exporting its own remote objects, which can be passed to the (other) server, which can then use that remote object to call the client back.