O'Reilly logo

Special Edition Using Java™ 2 Enterprise Edition by Mark Wutka

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required