/*
 * list RMI registry
 *
 */

import java.net.*;
import java.rmi.*;

public class listrmireg {

  /*parameters */
  public static String host = ""; 
  public static int port = -1; 
 
  public static void main(String[] args) 
         throws InterruptedException {

    if (args.length >= 1) { 
       host = args[0]; 
    } 
    System.out.println("RMI registry: " + host + "\n");

    if (host == "") { return; } 

    /* list */
    try { String s[] = Naming.list(host); 
          for (int i=0; i < s.length; i++) {
              System.out.println(i + ") " + s[i]);
          }
          if (s.length > 0) { System.out.println(); } 
          System.out.println("all entries listed.");
    }
    catch (MalformedURLException u) {
      System.err.println("MalformedURL in host:" + host);
      System.exit(-1);
      } 
    catch (RemoteException re) {
      System.err.println("Cannot contact registry on:" + host);
      System.exit(-1);
      } 

  }
}




