Can you attach to a running application using Eclipse, similar to how you attach using Visual Studio?
您是否可以使用Eclipse附加到正在运行的应用程序,类似于使用Visual Studio进行附加的方式?
3 个解决方案
#1
48
Yes.
是。
If you start your server with the debug port open, by adding this into your java command:
如果在打开调试端口的情况下启动服务器,请将其添加到java命令中:
-Xdebug -Xrunjdwp:transport=dt_socket,address=127.0.0.1:8888,server=y,suspend=n
And you have the source code in your project (technically this isn't required, but it's kind of useless unless you do), you can connect to the running server by setting up a "debug configuration" with host = the machine the server is running on and port = 8888 (for example - see options above)
并且您在项目中有源代码(技术上这不是必需的,但除非您这样做,否则它是无用的),您可以通过设置“调试配置”来连接到正在运行的服务器,主机=服务器所在的机器运行和port = 8888(例如 - 参见上面的选项)
You can then set break points and the debug session will halt the server there and you can inspect variables/fields, and even set their values.
然后,您可以设置断点,调试会话将暂停服务器,您可以检查变量/字段,甚至设置它们的值。
Update
更新
The more modern command-line options for the JVM to do this are
JVM执行此操作的现代命令行选项更为现实
-agentlib:jdwp=transport=dt_socket,address=127.0.0.1:8888,server=y,suspend=n
#2
26
The Debug Configurations panel has a menu item Remote Java Application
:
Debug Configurations面板有一个菜单项Remote Java Application:
#3
-3
How about just do this:
这样做怎么样:
"Open the DDMS perspective, select the device and attach to your app's process (you will see the package name listed)"
“打开DDMS透视图,选择设备并附加到应用程序的进程(您将看到列出的软件包名称)”
.. thanks to this post: https://*.com/a/10074263/2162226
..感谢这篇文章:https://*.com/a/10074263/2162226
#1
48
Yes.
是。
If you start your server with the debug port open, by adding this into your java command:
如果在打开调试端口的情况下启动服务器,请将其添加到java命令中:
-Xdebug -Xrunjdwp:transport=dt_socket,address=127.0.0.1:8888,server=y,suspend=n
And you have the source code in your project (technically this isn't required, but it's kind of useless unless you do), you can connect to the running server by setting up a "debug configuration" with host = the machine the server is running on and port = 8888 (for example - see options above)
并且您在项目中有源代码(技术上这不是必需的,但除非您这样做,否则它是无用的),您可以通过设置“调试配置”来连接到正在运行的服务器,主机=服务器所在的机器运行和port = 8888(例如 - 参见上面的选项)
You can then set break points and the debug session will halt the server there and you can inspect variables/fields, and even set their values.
然后,您可以设置断点,调试会话将暂停服务器,您可以检查变量/字段,甚至设置它们的值。
Update
更新
The more modern command-line options for the JVM to do this are
JVM执行此操作的现代命令行选项更为现实
-agentlib:jdwp=transport=dt_socket,address=127.0.0.1:8888,server=y,suspend=n
#2
26
The Debug Configurations panel has a menu item Remote Java Application
:
Debug Configurations面板有一个菜单项Remote Java Application:
#3
-3
How about just do this:
这样做怎么样:
"Open the DDMS perspective, select the device and attach to your app's process (you will see the package name listed)"
“打开DDMS透视图,选择设备并附加到应用程序的进程(您将看到列出的软件包名称)”
.. thanks to this post: https://*.com/a/10074263/2162226
..感谢这篇文章:https://*.com/a/10074263/2162226