Java jdb远程调试命令行工具

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/87885/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 11:00:29  来源:igfitidea点击:

Java jdb remote debugging command line tool

javajdb

提问by bmw0128

anyone have any experience using this? if so, is it worth while?

任何人有使用这个的经验吗?如果是这样,值得吗?

采纳答案by Johan

I just used jdb for the first time yesterday and am really pleased with the results. You see, I program in Eclipse on my laptop, then deploy to a VM to make sure the whole shebang still works. Very occasionaly, I'll have to work on something that gets executed standalone, as a commandline. These things sometimes need debugging.

我昨天第一次使用 jdb,对结果非常满意。你看,我在笔记本电脑上的 Eclipse 中编程,然后部署到 VM 以确保整个 shebang 仍然有效。偶尔,我将不得不处理一些作为命令行独立执行的工作。这些东西有时需要调试。

This has always been a problem, because I don't want to go to the trouble of installing Eclipse on the VM (it's slow enough already!), yet I don't know of an easy way to get it to connect to my commandline-running class before it finishes running.

这一直是个问题,因为我不想麻烦在 VM 上安装 Eclipse(它已经够慢了!),但我不知道有什么简单的方法可以让它连接到我的命令行- 在完成运行之前运行类。

jdb to the rescue! It works a treat - small and functional, almost to the point where it is bare... this forces you to apply your mind more than you apply the tool (like I said here).

jdb 来救援!它工作得很好 - 小而实用,几乎到了裸露的地步......这迫使您更多地运用您的思想而不是您应用工具(就像我在这里说的那样)。

Make sure to print out the reference (solaris, windows, java 1.5- I think they're all about the same, really) and have your source code open and browsable on your second screen. I hope you have a second screen, or you'll be alt-tabbing a lot.

确保打印出参考(solariswindowsjava 1.5- 我认为它们都差不多,真的)并且让你的源代码在你的第二个屏幕上打开和浏览。我希望你有第二个屏幕,否则你会经常使用 alt-tab。

回答by Evans Y.

Assume your program is started by the following command:

假设您的程序由以下命令启动:

java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=<port> <class>

You can attach to this process by jdb:

您可以通过 jdb 附加到此进程:

jdb -attach <port>

回答by Evans Y.

JDB is incredibly difficult to use. Placing System.outs or using an IDE debugger will produce better results. And for the more interesting features (e.g. tracking threads, heap size, etc.), you can get the information graphically with the JConsoletool.

JDB 非常难以使用。放置 System.outs 或使用 IDE 调试器会产生更好的结果。对于更有趣的功能(例如跟踪线程、堆大小等),您可以使用JConsole工具以图形方式获取信息。