需要在命令行中提供一个参数指明servername
如果server固定的话,直接改Client的main方法,把servername指定就好了

解决方案 »

  1.   

    你打了参数吗?
    java Client 4321
    应该是这样吧!
      

  2.   

    加了这句:
    serverName = new String("localhost");
    还是不行。
      

  3.   

    public static void main(String[] args)
    {
                      /*
    if (args.length < 1)
    {
    System.out.println("you forget the name of server!");
    System.exit(0);
    }
                      */
                       String serverName = "localhost";
    Client client = new Client();
    client.setVisible(true);
    //connectServer(args[0]);
                      connectServer(serverName); 
    }
      

  4.   

    Error: java.net.ConnectException: Connection refused: connect
    现在改了。还是出现上面的错误。