public static void main(String[] args) throws Exception {
		
		CommandLine cmd = null;
		String host = ClientApp.DEFAULT_HOST;
		int port = ClientApp.DEFAULT_PORT;
		
		cmd = ClientApp.parseArgs( args );
		
		if( cmd != null ) {
			
			if ( cmd.hasOption("host") ) {
				host = cmd.getOptionValue("host");
			}
			
			if ( cmd.hasOption("port") ) {
				port = Integer.parseInt( cmd.getOptionValue("port") );
			}
			
			boolean connected = ClientApp.connectToServer( host, port );
			
			if( !connected ) {
				System.out.println("Error connecting to RMI. Please see stack trace");
			} else {
				
				Scanner in = new Scanner( System.in );
				IView view = new ConsoleView( in , System.out );
				
				if ( cmd.hasOption("gui") ) {
					view = new GraphicView();
				}
				Client client = new Client( ClientApp.server, view );
				
				boolean exported = ClientApp.exportClient( client );
				
				if( !exported ) {
					System.out.println("Error exporting client to RMI. Please see stack trace");
				} else {
					
					client.connect();

					if ( cmd.hasOption("gui") ) {
						((GraphicView)view).setVisible(true);
					}
					
					//TODO: remove this
					while( !client.isGameFinished() ) {
						Thread.sleep( 2000 );
					}
				}
				
			}			
			
		}

	}