public class JOSServer implements ServiceIDListener, DiscoveryListener {              

// register with any LUS supporting public groups        
String[] groups = new String[] { "" }; 

// define specific LUS locations for unicast discovery 
LookupLocators[] locs = { "jini://%HOST_NAME%:4159" };

// define specific service attributes e.g. Name and ServiceInfo
private Entry[] entries  = {  new Name("JOSInterface"),              
                                  new ServiceInfo("JavaOfficeSpace",  
                                  "Robert Flenner",  
                                  "O'Reilly",  
                                  "1.0","", "") };  

// supply a lease manager for our service 
LeaseRenewalManager lrm = new LeaseRenewalManager();

// we don't have a service id yet  
ServiceID id = null;

// table to save service items 
private Hashtable lookups = new Hashtable();   

// the service to register
JOSpace obj;

public JOSServer() {
   try {     
          if (System.getSecurityManager() == null) {          
              System.setSecurityManager(new RMISecurityManager());          
          }          

// the service that you are registering
obj = new JOSpace();

// we will use a unicast and multicast discovery process
LookupDiscoveryManager ldm = new 
LookupDiscoveryManager(groups, locs, this); 

if(id != null) { 
   // we have a service id 
   JoinManager jm = new JoinManager(obj, entries, id, ldm, lrm);  
} else { 
   // we will have a service id assigned  
   JoinManager jm = new JoinManager(obj, entries, this, ldm, lrm);  
        } 

        } catch (Exception e) {  
            e.printStackTrace(); 
            System.out.println("Unable to initialize service...exiting!"); 
            System.exit(1); 
        } 
}