System.setSecurityManager(new RMISecurityManager());
// Create the lookup manager to discover lookup services
ClientLookupManager clm = new ClientLookupManager(null, null);
Class[] name = new Class[] { ConvertService.class };
ServiceTemplate st = new ServiceTemplate(null, name, null);
// Block until a matching service is found
ServiceItem[] si = clm.lookup(st, 1, 1, null, Long.MAX_VALUE);
if (si == null || si.length == 0)
throw new Exception("Can't find service");
ConvertService cs = (ConvertService) si[0].service;
// Now invoke methods on the service object
System.out.println(cs.convert(5));
clm.terminate();