2016-12-24 59 views
0

我必须编写两个程序:服务器和客户端 - 在某个端口上运行服务器,同时在该端口上运行客户端。我在我的计算机上运行所有内容,并将客户端程序的参数作为机器地址的本地主机,但出于某种原因,它被视为jarfile。我有:错误:无法访问jarfile localhost

String hostname = args[0]; 
int port = Integer.parseInt(args[1]); 
... 
Socket socket = new Socket(hostname, port); 
... 

与调用它:

java -jar client.jar localhost 1234 

但我收到以下错误:

Error: unable to access jarfile localhost

回答

0

发现了它。我没有密封整个JAR,只是一些软件包,所以我的程序没有将localhost识别为机器地址。