Home : Course Map : Chapter 13 :
RMI - Remote Method Invocation
JavaTech
Course Map
Chapter 13

Network Overview
Internet Basics
IP - Datagrams
  TCP - UDP
  Application Layer
Ports
Java Networking
URL
  Demo 1
Read From URL
  Demo 2
InetAddress
  Demo 3   Demo 4
Sockets
  Demo 5
Client-Server

RMI
Exercises

     About JavaTech
     Codes List
     Exercises
     Feedback
     References
     Resources
     Tips
     Topic Index
     Course Guide
     What's New

Chapter 18 here and in the book discusses the RMI framework in detail. Here we give a brief overview.

The RMI system in Java allows an object running in one JVM on one host to invoke the method of a remote object that is running in another VM on another host just as if they were both in the same JVM on the same platform. To do this, RMI allows objects to be passed back and forth (when the objects are Serializable) over the network

Sockets involve network communications at a fairly low level that require detailed handling of the socket setup, protocols, etc. RMI provides a higher level of networking where much of the networking machinery is hidden. An object calls methods of the remote object just as if the remote object was running locally.

Typically, RMI setups are discussed in terms of a client that runs methods on a server on a remote host. (However, there's no reason the server could not invoke methods on the client, as well. So the terminology can be somewhat misleading.)

Setting up RMI programs requires several steps. On the server side the objects need to implement a sub-class of the Remote interface that implemented by the objects to be remotely invoked. Also, the objects must extend UncastRemoteObject.

The Registry program on the server side must be activiated. It is what the client interacts with to find the objects of interest. The server must register or bind the name of its object with the registry.

A special RMI compiler called rmic is run on the server to create the Stub and Skeleton classes that carry out the lower level interaction.

The client program connects to the remote registry with a special URL protocol called rmi. For example, to look up the remote object, the registry lookup is passed a string such as rmi://www.ace.com/NameOfRemoteObject.

While it appears the client is invoking a remote method, it actually invokes a method on a special local object called a Stub that is passed to the local host when the connection to the Registry is made.

The Stub in turn talks not directly to the remote object but instead talks with a special object called a Skeleton that is running on the Server side and carries out the method invocation.

All of this can get rather confusing to describe but once one does it in practice it is not so bad. See Chapter 18 for further discussion.

References & Web Resources

 

Latest update: Dec. 8, 2004
  
  Part I Part II Part III
Java Core 1  2  3  4  5  6  7  8  9  10  11  12 13 14 15 16 17
18 19 20
21
22 23 24
Supplements

1  2  3  4  5  6  7  8  9  10  11  12

Tech 1  2  3  4  5  6  7  8  9  10  11  12
Physics 1  2  3  4  5  6  7  8  9  10  11  12

Java is a trademark of Sun Microsystems, Inc.