Java Remote Method Invocation
Mohammad Masudur Rahman
Department of Computer Science
University of Saskatchewan
Saskatoon, Canada
[email protected]
AbstractJava Remote Method Invocation (RMI) is a dis-
tributed object technology which allows an application to invoke
methods from remote java objects hiding socket level details. It
can be considered as an object version of Java RPC. It is mainly a
java-centric technology and it has three major parts - client part
which invokes the remote method, server part which allows client
to invoke methods and RMI registry which maintains the remote
object references for both client and server. This is an easy to
use, cross-platform distributed object technology which leverages
the whole power of Java technology. In this tutorial, we have
provided an overview of Java RMI technology and developed
a simple RMI application. We have also discussed about the
strengths and weaknesses of the technology which is followed
by a comparative study between RMI and another distributed
object technology called CORBA.
Index TermsJava RMI; Distributed Object; RPC; IIOP;
CORBA
I. INTRODUCTION
Remote method invocation (RMI) is a technology that
allows applications to call object methods located remotely,
sharing resources and processing load across systems in a
distributed environment. It facilitates object function calls
between Java Virtual Machines (JVMs). JVMs can be located
on separate computers - yet one JVM can invoke methods
belong to an object stored in another JVM[3]. Java has built-
in support for RMI throughJava RMI AP I. The original
implementation depends on Java Virtual Machine (JVM) class
representation mechanisms and it thus only supports making
calls from one JVM to another. The protocol underlying this
Java-only implementation is known as Java Remote Method
Protocol (JRMP). In order to support code running in a non-
JVM context, there is also a version compliant with CORBA
technology [17].
Unlike other systems for remote execution which require
that only simple data types or dened structures be passed to
and from methods, RMI allows any Java object type to be used
- even if the client or server has never encountered it before[3].
It can be also considered as an object version of Remote
Procedure Call (RPC). RMI allows both client and server
to dynamically load new object types as required. Basically,
RMI uses object serialization
1
to marshal
2
and unmarshal
parameters and does not truncate types, supporting true object-
oriented polymorphism.
1
A process to convert the object into a stream of bytes suitable for storage
or transmission over network
2
A similar process like serialization except it records object's state, code
base and treat remote objects specially[11]
Java RMI is a distributed object technology and it has
two parts- client and server. However, client and server don't
communicate directly, rather client proxy object communicates
with server stub object and emulates the remote method
invocation as a local object function call.
In this tutorial, we have provided an overview about Java
RMI technology and implemented a simple RMI application
for mathematical operations. We tried to discover the strengths
and weaknesses of RMI and also performed its comparative
study against another distributed object technology called
CORBA. However, rest of the tutorial is structured as follows.
Section II focuses on the historical perspective of Java
RMI technology in brief.
Section III denes few technical terminologies required
to understand the architecture or functionalities of our
target technology.
Section IV discusses how different components of RMI
architecture operate with each other.
Section V demonstrates the implementation and deploy-
ment of a simple Java RMI application for mathematical
operations.
Section VI highlights some advanced topics related to
Java RMI
Section VII illustrates the strength and weakness of the
technology
Section VIII provides a comparative study between Java
RMI and CORBA technology.
Section IX concludes the tutorial
II. HISTORICALBACKGROUND[7]
Distributed systems require that computations running in
different address spaces, potentially on different hosts, be
able to communicate. For a basic communication mechanism,
the Java programming language supports sockets, which are
exible and sufcient for general communication. However,
sockets require the client and server to engage in applications-
level protocols to encode and decode messages for exchange,
and the design of such protocols is cumbersome and can be
error-prone.
An alternative to sockets is Remote Procedure Call (RPC)
developed in late 1970's, which abstracts the communication
interface to the level of a procedure call. Instead of working
directly with sockets, the programmer has the illusion of
calling a local procedure, when in fact the arguments of the
call are packaged up and shipped off to the remote target of the