Suppose we are building an application to perform diverse mathematical operations. Let's design a project that can sit on a server. Post this, have different client projects interact with this project to pass the parameters and get the computation on the remote object execute and return the result to the client components. This needs the remote interface to be defined first, as discussed in the preceding section.
The following is the definition of the Calculate interface that extends the Remote interface:
package remote; import java.rmi.Remote; import java.rmi.RemoteException; publicinterface Calculate extends Remote { publiclong add(long parameterOne, long parameterTwo) throws RemoteException; publiclong sub(long parameterOne, long parameterTwo) throws RemoteException; publiclong mul(long parameterOne, long parameterTwo) throws RemoteException; publiclong div(long parameterOne, long parameterTwo) throws RemoteException; }