问题
In an app which I have programmed, I have a java.net.SocketException on a specific computer:
java.net.SocketException: Address family not supported by protocol family: connect
This specific computer runs Windows 7 32 Bit and is connected to the internet through Local Area Connection (Ethernet). The app runs correctly on other computers, with Windows 7 and Windows 8, connected through Local Area Connection or through Wi-Fi, so I am actually not sure that the problem is programmatic. I have tried to check the protocols of the Local Area Connection, but I didn't see any problems. Can someone please help me understand what is the problem? Why is this exception thrown?
回答1:
Try to check whether the spy program called "RelevantKnowledge" is installed. Its uninstallation helped me to solve the problem.
回答2:
For me Java option -Djava.net.preferIPv4Stack=true
did the trick
回答3:
- Open command prompt (windows start button, type cmd in search)
- Click top left of command prompt, click properties, enable quick edit mode
Copy:
setx _JAVA_OPTIONS -Djava.net.preferIPv4Stack=true
Right click on command prompt, should paste
- Hit enter. That easy!
回答4:
It may be a few things:
- Anti-virus blocking the connection. If you have an anti-virus running on that computer, try disabling it for a test.
- Java 7 trying to use IPv6 to connect: if you have Java 6 on the computers where it works and Java 7 where it fails, try disabling IPv6 in Java on the computer where it fails (instructions in this post)
回答5:
If you are using java 6, try to change to java 7. It works for me.
回答6:
Thanks this helped me :
Anti-virus blocking the connection. If you have an anti-virus running on that computer, try disabling it for a test.
Open command prompt (windows start button, type cmd in search) Click top left of command prompt, click properties, enable quick edit mode Copy: setx _JAVA_OPTIONS -Djava.net.preferIPv4Stack=true Right click on command prompt, should paste Hit enter. That easy!
来源:https://stackoverflow.com/questions/16373906/address-family-not-supported-by-protocol-family-socketexception-on-a-specific