Being able to use sockets explicitly is necessary in order to communicate with existing applications and non-Java applications, but now, both the applet and our threaded server are written in Java. Therefore, we can use Remote Method Invocation instead.
Remote Method Invocation, introduced in Java 1.1, lets a method call methods in objects that reside on another computer. Internally, this is handled using object serialization, but the details are hidden from the programmer, who only sees ordinary method calls.
You should read the Getting Started document in the JDK 1.1 documentation. Follow the instructions and create a distributed Hello World program. Make sure that you understand what happens when you run the program.
See also the complete RMI documentation.
The Exceptions In RMI part of the RMI specification also contains some useful information.
Make a copy of your guest book applet and guest book server code. Instead of using sockets explicitly, your new applet should make remote method calls directly into the server; therefore, the server no longer needs to be threaded.
If you get unexplainable exceptions, make sure that your applet and your server use the
same version of the stub code generated by rmic and that the rmiregistry is
running.