The location where Pi class is available is set using the -Djava.rmi.server.codebase=file:/c:/home/jones/public_html/classes/ command line arg on client side.
When the remote method is called, server finds that it doesn't know the class Pi whose instance is sent by this client. So the RMI infrastructure loads the classes from the codebase specified by the same client. If another client sends a class Pi2 with a different codebase, the server side will load Pi2 from the second codebase. Each client can specify its own codebase. The server also can specify its own codebase to serve classes required by clients.
A great way to understand what's going on in the RMI infrastructure on server side, client side and in registry is
- start all of them with the command line arg -Djava.util.logging.config.file=rmilogging.properties
- Create this file "rmilogging.properties" in the same directory with the following contents:
subject: How class will be loaded in the server in RMI?