What is a remote interface in java?

A Remote interface is available in the java.rmi package it is a marking/tagging interface, it is used with remote method invocation(RMI).

RMI is a mechanism that allows an object residing in one system (JVM) to access/invoke an object running on another JVM.

To it is a marking interface, to mark an object of a class remote, you need to implement this interface.

To create a remote interface −

  • Create an interface that extends the predefined interface Remote which belongs to the package or, implement the Remote interface with the class, which you need to make remote.

  • Declare all the business methods that can be invoked by the client in this interface.

  • Since there is a chance of network issues during remote calls, an exception named RemoteException may occur; throw it.


import java.rmi.Remote;
import java.rmi.RemoteException;
// Creating Remote class for our application
public class RemoteExample implements Remote {
import java.rmi.Remote;
import java.rmi.RemoteException;
// Creating Remote interface for our application
public interface Hello extends Remote {
   void printMsg() throws RemoteException;

Updated on: 29-Jun-2020

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started