开发者

Args error in main method for client-server program

Hi I have a client and server program, all the coding is done and compiles, the client has a GUI and the server is command line. The program uses sockets.

But when I run the client to connect to the se开发者_如何学JAVArver it keeps coming with the error message: "Usage: TodoClient []", rather than connecting to the server and starting up.

This is where the problem lies:

 public static void main(String[] args) {

TodoClient client;



if (args.length > 2 || args.length == 0) {

  System.err.println("Usage: TodoClient <host> [<port>]");

} else if (args.length == 1) {

  client = new TodoClient(args[0], DEFAULT_PORT);

} else {

  client = new TodoClient(args[0], Integer.parseInt(args[1]));

}

}

Thank You


You are running this with a host and optional port, aren't you ?

e.g.

java TodoClient localhost 8080
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜