public static void main(String[] args) {
		try {
			Console console = System.console();
			if (console == null) {
				System.err.println("Error : No console ! Please run it with command line :).");
				System.exit(1);
			}

			// System.setSecurityManager(new java.rmi.RMISecurityManager());

			ILoginModule lm = (ILoginModule) Naming.lookup("LoginModule");
			IClient client = new Client();

			String login = console.readLine("Please enter your login \t: ");
			String password = console.readLine("Please enter room's password \t: ");

			client.setName(login);
			SPClient spClient = new SPClient(client);

			final SPClient c2 = new SPClient(client);
			Runtime.getRuntime().addShutdownHook(new Thread() {
				public void run() {
					try {
						c2.getChatroom().logout(c2);
					} catch (RemoteException e1) {
						e1.printStackTrace();
					}
				}
			});

			client.setFrame(new ClientFrame(spClient));
			IChatroom cr = lm.login(spClient, password);
			if (cr != null) {
				client.setChatroom(cr);
				client.getFrame().visible(true);
				client.setConnected(true);
			}
			while (!client.isConnected()) {
				System.out
				          .println("Connection failed : incorrect password or login already in use.");
				login = console.readLine("Please enter your login \t: ");
				password = console.readLine("Please enter room's password \t: ");
				client.setName(login);
				spClient = new SPClient(client);
				cr = lm.login(spClient, password);
				if (cr != null) {
					client.setChatroom(cr);
					client.getFrame().visible(true);
					client.setConnected(true);
				}
			}
			return;
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (RemoteException e) {
			e.printStackTrace();
		} catch (NotBoundException e) {
			e.printStackTrace();
		}
	}