Hi, Luke. I run your code with no change and got desired output.
Probably you have a problem with a firewall which disallows that kind of connection. Check it's settings. You may even disable firewall for some time to check if your problem is really caused by it. Note that in most cases "application name" in firewall's settings should be a "java" , "java.exe" or full path to
java executable but not name of your class.