'Hello World' example of an Applet using Java RMI

'Hello World' example of an Applet using Java RMI (Remote Method Invocation), with source code and notes included.

Source Code

The files for this example should all be placed in the same directory.

Compiling and Running

These commands to be executed from the directory where the above files are:

  1. Compile the code (i.e., Server.java, ClientApplet.java, and RemoteInterface.java).
    This will generate Server.class, ClientApplet.class, and RemoteInterface.class
    javac *.java
  2. Compile the server with the RMI compiler.
    For Java versions before 1.5
    rmic -v1.2 Server
    For Java versions 1.5 and later
    rmic Server
    this will generate the file: Server_Stub.class
  3. Start the RMI registry service and run it in the background.
    (Usage)   rmiregistry [port] &
    By default, the RMI registry listens on port 1099.
    There is no need to restart the RMI registry if it is already running.
    A Java program to see if a RMI registry is running and what names are registered in it.
    (Unix)   rmiregistry 3273 &
    (Windows)   start rmiregistry 3273
  4. Start the server and run it in the background.
    (Unix)   java Server &
    (Windows)   start java Server
  5. Open a web-browser and view applet.html

If the applet does NOT work, here are some possible reasons why