import net.jini.core.entry.*;
import net.jini.core.lookup.*; 
import net.jini.core.discovery.*;    
import net.jini.lookup.entry.*; 
import java.rmi.*;

/***************************************************************************

    MyClient -- The Jini Client Class

 ***************************************************************************/

    class MyClient
      {
      public static void main (String[] args)
        {
        Entry[] aeAttributes;
        LookupLocator lookup;  
        ServiceRegistrar registrar;
        ServiceTemplate template;
        MyServerInterface myServerInterface;

        try 
          {
          System.setSecurityManager (new RMISecurityManager ());
          System.out.println ("*-----------------------------------------"
            + "--------------------------------*");

          lookup = new LookupLocator ("jini://localhost");
          registrar  = lookup.getRegistrar ();
          System.out.println ("client: got proxy1 to Lookup         [" 
            + registrar.getClass().getName() + "]");

          aeAttributes = new Entry[1];
          aeAttributes[0] = new Name ("MyServerName");
          template = new ServiceTemplate (null, null, aeAttributes);
          myServerInterface = (MyServerInterface) registrar.lookup (template);
          System.out.println ("client: got proxy2 to MyServer       [" 
            + myServerInterface.getClass().getName() + "]");

          if (myServerInterface instanceof MyServerInterface)
            {
            System.out.println 
              (
              "client: called proxy2.sayHello()     ---->" 
                + myServerInterface.sayHello ()  + "<----"
              );
            }
          System.out.println ("*-----------------------------------------"
            + "--------------------------------*\n");
          } 

        catch (Exception e) 
          {
          System.out.println ("main(): " + e);
          }
        }
      }

