The Server
The setup procedure should
package compute;

            import java.rmi.Remote;
            import java.rmi.RemoteException;

            public interface Compute extends Remote {
                Object executeTask(Task t) throws RemoteException;
            }
-------------------------------------------------------------------------
package compute;

            import java.io.Serializable;

            public interface Task extends Serializable {
                Object execute();
            }
--------------------------------------------------------------------------
package engine;

            import java.rmi.*;
            import java.rmi.server.*;
            import compute.*;

            public class ComputeEngine extends UnicastRemoteObject
                                       implements Compute
            {
                public ComputeEngine() throws RemoteException {
                    super();
                }

                public Object executeTask(Task t) {
                    return t.execute();
                }

                public static void main(String[] args) {
                    if (System.getSecurityManager() == null) {
                        System.setSecurityManager(new RMISecurityManager());
                    }
                    String name = "//host/Compute";
                    try {
                        Compute engine = new ComputeEngine();
                        Naming.rebind(name, engine);
                        System.out.println("ComputeEngine bound");
                    } catch (Exception e) {
                        System.err.println("ComputeEngine exception: " + 
                                           e.getMessage());
                        e.printStackTrace();
                    }
                }
            }
The Server -- UnicastRemoteObject
UnicastRemoteObject is a convenience class, defined in the RMI public API, that can be used as a superclass for remote object implementations. The      superclass UnicastRemoteObject supplies implementations for a number of java.lang.Object methods (equals, hashCode, toString) so that they are defined appropriately for remote objects. UnicastRemoteObject also includes constructors and static methods used to export a remote object, that is, make the remote object available to receive incoming calls from clients.  Once the export step is complete, the ComputeEngine remote object is ready to accept incoming calls from clients on an anonymous port, one chosen by RMI or the underlying operating system.

A remote object implementation does not have to extend UnicastRemoteObject, but any implementation that does not must supply appropriate      implementations of the java.lang.Object methods. Furthermore, a remote object implementation must make an explicit call to one of UnicastRemoteObject's exportObject methods to make the RMI runtime aware of the remote object so that the object can accept incoming calls. By extending UnicastRemoteObject, the ComputeEngine class can be used to create a simple remote object that supports unicast (point-to-point) remote communication and that uses RMI's default sockets-based transport for communication.

The Server -- Security Managers
Security manager protect access to system resources from untrusted downloaded code running within the virtual machine. The security manager determines whether downloaded code has access to the local file system or can perform any other privileged operations.

All programs using RMI must install a security manager, or RMI will not download classes (other than from the local class path) for objects received as parameters, return values, or exceptions in remote method calls. This restriction ensures that the operations performed by downloaded code go through a set of security checks.

The ComputeEngine uses a security manager supplied as part of the RMI system, the RMISecurityManager. This security manager enforces a similar security policy as the typical security manager for applets; that is to say, it is very conservative as to what access it allows.

The Server -- The Registry
Note the following about the arguments to the call to Naming.rebind.