简体   繁体   中英

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 . 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

Found it. I didn't seal whole JAR, just some packages, so my program didn't recognize localhost as an address of machine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM