As other people have pointed out, it is most likely related to another process using port 9999
. On Windows, run the command:
netstat -a -n | grep "LIST"
And it should list anything there that's hogging the port. Of course you'll then have to go and manually kill those programs in Task Manager. If this still doesn't work, replace the line:
serverSocket = new ServerSocket(9999);
With:
InetAddress locIP = InetAddress.getByName("192.168.1.20");
serverSocket = new ServerSocket(9999, 0, locIP);
Of course replace 192.168.1.20
with your actual IP address, or use 127.0.0.1
.