// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.io.IOException;
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.util.ArrayList;

public class Server {
    public static void main(String[] args) {
        try {
            ArrayList lst = new ArrayList();
            lst.add(new DataImpl(1, "A"));
            lst.add(new DataImpl(2, "BB"));
            lst.add(new DataImpl(3, "CCC"));
            LocateRegistry.createRegistry(9999);
            Naming.rebind("rmi://localhost:9999/Foobar", new FoobarImpl(lst));
            System.out.println(lst);
            System.out.print("Press enter to continue");
            System.in.read();
            System.out.println(lst);
            System.exit(0);
        } catch (RemoteException e) {
            e.printStackTrace();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
