import net.jini.core.entry.Entry; import net.jini.core.discovery.LookupLocator; import net.jini.core.lookup.ServiceRegistrar; import net.jini.core.lookup.ServiceTemplate; import net.jini.lookup.entry.Name; import java.rmi.RMISecurityManager; public class MyClient { public static void main (String[] args) { Entry[] aeAttributes; LookupLocator lookup; ServiceRegistrar registrar; ServiceTemplate template; MyServerInterface myServerInterface; try { /* Set the security manager to allow the RMI class loader to access the codebase for classes that are not available locally */ System.setSecurityManager (new RMISecurityManager ()); /* Find the Jini lookup service (reggie) and print its location */ lookup = new LookupLocator ("jini://localhost"); /* Get the lookup service's ServiceRegistrar and perform a search to find the service that has the name attribute name of "HelloWorldServer". The lookup service returns an Proxy object to the service */ registrar = lookup.getRegistrar(); aeAttributes = new Entry[1]; aeAttributes[0] = new Name ("HelloWorldServer"); template = new ServiceTemplate (null, null, aeAttributes); myServerInterface = (MyServerInterface) registrar.lookup (template); System.out.println ("Calling sayHello()->" + myServerInterface.sayHello () + "<-"); } catch (Exception e) { System.out.println ("client: MyClient.main() exception: " + e); } } }