Java 协议族不支持地址族 - 特定计算机上的 SocketException
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16373906/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Address family not supported by protocol family - SocketException on a specific computer
提问by Or B
In an app which I have programmed, I have a java.net.SocketExceptionon a specific computer:
在我编写的应用程序中,我在特定计算机上有一个java.net.SocketException:
java.net.SocketException: Address family not supported by protocol family: connect
java.net.SocketException:协议族不支持地址族: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?
这台特定的计算机运行 Windows 7 32 位,并通过本地连接(以太网)连接到互联网。该应用程序在其他计算机上正常运行,使用 Windows 7 和 Windows 8,通过本地连接或通过 Wi-Fi 连接,所以我实际上不确定问题是编程性的。我试图检查本地连接的协议,但没有发现任何问题。有人可以帮我理解是什么问题吗?为什么会抛出这个异常?
采纳答案by bronixx
Try to check whether the spy program called "RelevantKnowledge" is installed. Its uninstallation helped me to solve the problem.
尝试检查是否安装了名为“RelevantKnowledge”的间谍程序。它的卸载帮助我解决了这个问题。
回答by Christian Garbin
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)
- 阻止连接的防病毒软件。如果您在该计算机上运行了防病毒软件,请尝试将其禁用以进行测试。
- Java 7中尝试使用IPv6连接:如果你有Java 6中,其中它的工作原理和Java 7中失败的计算机上,尝试它无法在计算机上的Java关闭IPv6(说明在这个岗位)
回答by mibutec
For me Java option -Djava.net.preferIPv4Stack=true
did the trick
对我来说 Java 选项-Djava.net.preferIPv4Stack=true
成功了
回答by mikemaal
If you are using java 6, try to change to java 7. It works for me.
如果您使用的是 java 6,请尝试更改为 java 7。它对我有用。
回答by Satya Kaveti
- 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!
- 打开命令提示符(windows 开始按钮,在搜索中输入 cmd)
- 单击命令提示符左上角,单击属性,启用快速编辑模式
复制:
setx _JAVA_OPTIONS -Djava.net.preferIPv4Stack=true
右键单击命令提示符,应粘贴
- 点击进入。这么简单!
回答by user7098304
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!
打开命令提示符(windows 开始按钮,在搜索中键入 cmd)单击命令提示符左上角,单击属性,启用快速编辑模式复制:setx _JAVA_OPTIONS -Djava.net.preferIPv4Stack=true 右键单击命令提示符,应粘贴按回车键。这么简单!