Now let's look at running the client program. We'll start by looking at the client as a standalone application, followed by a discussion of client applets.
The virtual machine on the client computer needs access to the class files for the client program itself and for the remote interface - you must install these files in the client's classpath. The client also needs access to the stub class, but you don't need to install this file on the client - the RMI runtime will automatically download stub classes on demand. Remember to take advantage of this feature, we needed to install a security manager in the client application. So instead of installing the stub class file on the client, we can place it on a computer that's running a web server.
When we run the client application (see the command prompt), we specify the codebase property to indicate where to find the stub class files. If you don't want to have the stubs downloaded dynamically, or if you don't have a web, you can instead manually copy the stub class files to the classpath on the client computer.
Note that once the stubs have been downloaded, all further interaction with the RMI server uses the RMI protocol. This includes lookups in the naming registry and remote method calls and returns.
And as we saw with the server, in JDK 1.2 and later, the client needs to use a policy file. Here we have copied the same policy file as used on the server to the client so we can easily reference it on the command line.
Note: it's also possible to have the stubs downloaded to the client using the ftp protocol instead of http. See the JDK documentation for details.