/* Interface for a shared data structure between distributed processes. The sample data structure is just a stack of strings. This is the only file that needs to be shared between server and clients. RMI service interfaces must extend the empty interface "Remote" */ import java.rmi.*; public interface rmistack extends Remote { // returns number of items in stack public int size() throws RemoteException; // pushes s on stack public void push(String s) throws RemoteException; // pops stack, returns null if stack empty public String pop() throws RemoteException; // like pop, but does not change stack: public String peek() throws RemoteException; } /* To run example, 1. compile all three files: rmistack.java, stackimpl.java and stackclient.java 2. start rmiregistry on the server: rmiregistry & 3. run the server-side program: java stackimpl & 4. run the client on the client host: java stackclient serverip where serverip is the ip address of the server. Use 127.0.0.1 for localhost. The firewalls between client and server must allow connections to port 1099, which is the default rmiregistry port. NAT boxes need to correctly forward this port. */