Introduction to RMI

RMI is the distributed object system that is built into the core Java environment. You can think of RMI as a built-in facility for Java that allows you to interact with objects that are actually running in Java virtual machines on remote hosts on the network. With RMI (and other distributed object APIs we discuss in other chapters of this book), you can get a reference to an object that “lives” in a remote process and invoke methods on it as if it were a local object running within the same virtual machine as your code (hence the name “remote method invocation”).

Another way to characterize RMI (and other remote object schemes) is in terms of the granularity of the distribution that it enables. The Java servlet and JSP APIs, described in Chapters 3 and 4, allow you to distribute applications at the user interface level. Putting a servlet or JSP frontend on your server-side object model serves to export a web-based (typically HTML) interface to your application, which any remote web browser can access. The Java networking APIs, embodied in the http://java.net\ and java.io packages, allow you to open up very narrow, low-level data connections to your Java process, for simple data exchanges or “heartbeat” purposes (make a successful connection and transmit a few bytes to confirm that a process is alive). RMI and other remote object systems fall somewhere in between the two. They allow you to export functionality at the object/component level, allowing remote ...

Get Java Enterprise in a Nutshell, Third 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.