Args error in main method for client-server program
Posted
by socket
on Stack Overflow
See other posts from Stack Overflow
or by socket
Published on 2010-05-06T22:00:54Z
Indexed on
2010/05/06
22:08 UTC
Read the original article
Hit count: 121
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 server 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
© Stack Overflow or respective owner