Creating an RMI Server Object

To implement a remote object, you must create a class that is a subclass of java.rmi. server.UnicastRemoteObject and implements one or more remote methods. You must write the implementation for the remote methods yourself, of course.

The main method of the server (the main doesn't need to be in the same class) must do one peculiar thing—it must set up a security manager like this:

if (System.getSecurityManager() == null)
{
    System.setSecurityManager(new RMISecurityManager());
}

Because of the way RMI can pass objects back and forth and perform dynamic class loading, you need a special security manager to make sure someone doesn't send you a bogus class file.

To activate your remote object (i.e. make it available ...

Get Special Edition Using Java™ 2 Enterprise Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.