[英]Error: unable to access jarfile localhost
I have to write two programs: server and client - running server on some port, running client also on that port. 我必须编写两个程序:服务器和客户端-在某个端口上运行服务器,也在该端口上运行客户端。 I run everything on my computer and as argument of client program I have localhost as machine address, but for some reason it is treated like jarfile .
我在计算机上运行所有内容,并作为客户端程序的参数,将localhost作为计算机地址,但是由于某种原因,它被视为jarfile 。 I have:
我有:
String hostname = args[0];
int port = Integer.parseInt(args[1]);
...
Socket socket = new Socket(hostname, port);
...
Calling it with: 调用它:
java -jar client.jar localhost 1234
But I am getting the following error: 但是我收到以下错误:
Error: unable to access jarfile localhost
错误:无法访问jarfile本地主机
Found it. 找到了。 I didn't seal whole JAR, just some packages, so my program didn't recognize localhost as an address of machine.
我没有密封整个JAR,只是密封了一些软件包,所以我的程序无法将localhost识别为机器地址。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.