public static void main(String[] args) {

        // Bind an object of interface type Server to this computer's registry
        try {
            Runtime.getRuntime().exec("rmiregistry");
        } catch (IOException e) {
            System.err.println("RMIRegistry Error " + e.toString());
        }
        try {
            Server obj = new AdminServerImpl();
            
            // Bind the remote object's stub in the registry
            Registry registry = LocateRegistry.getRegistry();
            registry.bind("Server", obj);
            System.err.println("Server ready");
        } catch (RemoteException re) {
            System.err.println("Remote Server Exception: " + re.toString());
        } catch (AlreadyBoundException abe) {
            System.err.println("Server Binding Exception: " + abe.toString());
        }

        // A button to terminate the server once it is no longer needed
        JFrame frame = new JFrame();
        JButton unbind = new JButton("Terminate Server");
        unbind.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                Registry registry = null;
                try {
                    registry = LocateRegistry.getRegistry();
                } catch (RemoteException e) {
                    e.printStackTrace();
                }
                try {
                    if (registry != null) {
                        registry.unbind("Server");
                    } else {
                        throw new RemoteException();
                    }
                } catch (AccessException e) {
                    e.printStackTrace();
                } catch (RemoteException e) {
                    e.printStackTrace();
                } catch (NotBoundException e) {
                    e.printStackTrace();
                }
                System.exit(0);
            }
        });
        frame.add(unbind);
        frame.setSize(new Dimension(200, 200));
        frame.setVisible(true);
    }