JAVA: Creating and Executing RMI Applications

Steps for developing RMI applications are as follows:

  1. Defining the remote interface
  2. Implementing the remote interface
  3. Writing the code for registering the object
  4. Writing the client that uses the remote objects
  5. Generating stubs (client proxies) and skeletons (server entities)
  6. Running the RMI Registry, server and client

 

# Defining the remote interface

A remote Interface by definition is the set of methods that can be invoked remotely by a client:

  • Clients program communicate to remote interfaces, not to classes implementing it.
  • To be a remote interface, an interface must extend the Remote interface of java.rmi package.
  • Each method must throw a java.rmi.RemoteException (or a superclass of RemoteException)

Example:

import java.rmi.Remote;

public interface ExampleInterface extends Remote {

public String printJava() throws java.rmi.RemoteException;

public void addAmount(int a, int b) throws java.rmi.RemoteException;

}

Leave a Reply

Your email address will not be published. Required fields are marked *

Table of contents