public static void main(String[] args) {
        Registry registry = null;       
        try {
            registry = LocateRegistry.createRegistry(Registry.REGISTRY_PORT);
            //registry = LocateRegistry.getRegistry();
        } catch (RemoteException rex) {
            System.err.println("RemoteException occured");
        }
        if (registry == null) {
            System.err.println("Cannot find registry");
            System.exit(0);
        }
        
        try {
            registry.rebind("ChatServer", new ChatServerImpl());
            // Es gibt auch eine statische Methode, die verwendet werden kann.
            // Naming.rebind ("TimeServer", new TimeServerImpl());
            System.out.println("ChatServerImpl registered as 'ChatServer' ...");
        } catch (java.rmi.ConnectException cex) {
            System.err.println("ConnectException while accessing registry (port = " + Registry.REGISTRY_PORT + ")");
            System.err.println("Run 'rmiregistry " + Registry.REGISTRY_PORT + "'");
        } catch (Exception ex) {
            System.err.println("Exception during server registration (port = " + Registry.REGISTRY_PORT + ")");
            System.err.println(ex.getMessage());
        }
    }