无法使用 Eclipse 在 Java 中进行调试

新手上路,请多包涵

我正在尝试使用 Eclipse 作为 IDE 在我的机器上调试一个简单的 Java 应用程序。当我尝试通过进入调试透视图来调试应用程序时,我设置了一个断点并开始调试。几秒后,弹出如下窗口:

Launching unicodeRead has encountered a problem. Cannot connect to VM

转储到控制台的消息如下:

 ERROR: transport error 202: connect failed: Connection refused
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [../../../src/share/back/debugInit.c:708]
FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)

我该如何纠正这个问题?为什么会这样?

原文由 Sriram 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 821
2 个回答

我只是有同样的问题。

昨天一切正常,现在什么都没有 - 与您给出的错误相同。我发现网络管理员同时进行了一些更改。一些防火墙的东西。问题是 Eclipse 试图在“本地主机”(和一些随机端口)建立与 JVM 的连接。当我尝试 ping 本地主机(或 127.0.0.1)时,我得到以下信息:

 C:\Windows\system32>ping 127.0.0.1
Pinging 127.0.0.1 with 32 bytes of data:
PING: transmit failed. General failure.
PING: transmit failed. General failure.
PING: transmit failed. General failure.
PING: transmit failed. General failure.

C:\Windows\system32>ping localhost
Ping request could not find host localhost. Please check the name and try again.

它接缝在某些情况下 DNS 有望解决这个问题,如果防火墙阻止 localhost 对 DNS 的请求 - 东西就会中断。我不得不更改主机文件并删除以下行中的注释,因此我不再依赖 DNS:

 # 127.0.0.1       localhost
# ::1             localhost

虽然写的是主机文件更改会立即生效,但我认为某些进程锁定了它并且在我的情况下需要重新启动。在那之后,一切都恢复正常了。

原文由 gonadarian 发布,翻译遵循 CC BY-SA 3.0 许可协议

有同样的问题,但解决方案是使用 -server=y 选项而不是 -server=n 运行应用程序。

前:

 java -agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=localhost:5005

后:

 java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=localhost:5005

原文由 vladimirror 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题