Multiple Remote Interfaces 



import java.rmi.Remote;
import java.rmi.RemoteException;

public interface Goodbye extends Remote {

 String sayGoodbye() throws RemoteException;
}



import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.RMISecurityManager;
import java.rmi.server.UnicastRemoteObject;

public class HelloImpl extends UnicastRemoteObject
        implements Hello, Goodbye 

{

    public HelloImpl() throws RemoteException { }

    public String sayHello() {
            return  "Hello World!";
        }

    public String sayGoodbye() {
            return  "Goodbye World!";
        } 

        public static void main(String args[]) {

        try {
            HelloImpl obj = new HelloImpl();
            Naming.rebind("HelloServer", obj);
            System.out.println("HelloServer bound in registry");
            } catch (Exception e) {
                 System.out.println("HelloServer err: " + e.getMessage());
                 e.printStackTrace();
            }
       }
   }



import java.rmi.Naming;
import java.rmi.RemoteException;

public class GoodbyeClient
{

    public static void main(String arg[]) {

        String message = "blank";

        try {

            Goodbye obj = (Goodbye) Naming.lookup("rmi://"
                                                + "lysander.cs.ucsb.edu"
                                                + "/HelloServer");
            System.out.println(obj.sayGoodbye());
        } catch (Exception e) {
            System.out.println("GoodbyeClient exception: " + e.getMessage());
            e.printStackTrace();
        }
    }
}