eclipse 在调试模式下启动 java 进程的默认属性是什么?
我想使用命令行调试器连接到由 eclipse 启动的 java 进程,但不确定 eclipse 启动的 java 进程的默认属性是什么?我不介意使用套接字进行连接,但不确定这会慢多少?
I would like to connect to java process started by eclipse using a command line debugger but not sure what default properties of the eclipse launched java process are ? I wouldn't mind using attaching using sockets but not sure how much slower that would be ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
怎么样?
那么你可以将 java 调试器连接到端口 12345
how about
then you can attach a java debugger to port 12345
我研究了 Eclipse 中 Java 应用程序启动时“运行”和“调试”之间的差异。当使用任一选项启动 Java 应用程序时,我使用 Sysinternals 的 Process Explorer 查看 Eclipse 派生的 java 进程的命令行。 (我在 Windows 7 系统上)
使用“Run HelloWorld”
.......
使用“Debug HelloWorld”
(地址端口在后续调用中发生了变化,例如它变成了
address=localhost:2564
在下一次调用时。)因此,java(或 javaw)实际上根据是否使用“运行”或“调试”以不同的选项启动:“调试”启动添加了一个额外的
agentlib:jdwp=transport=dt_socket,suspend=y,地址=本地主机:NNNN 选项。这是将 JVM 置于可调试模式的标准方法。 HelloWorld 程序将首先等待其调试器成功连接到它,然后再继续(选项
suspend=y
)。 HelloWorld JVM 将自动连接到在地址 localhost:NNNN 上运行的某个调试器(...选项address=localhost:NNNN
和隐式默认选项server=n
)。 (... Oracle 提供了有关的权威信息agentlib
启动选项)Eclipse 本身将充当调试器应用程序,提供端口 NNNN。 HelloWorld JVM 将通过其自己的编号为 NNNN+1 的端口连接到此端口(可以使用 Process Explorer 在该进程的 TCP/IP 选项卡上查看该进程使用的端口)。
I investigated on the differences of Java application startup in Eclipse between "Run" and "Debug". I used Sysinternals' Process Explorer to see the command line of the java process that Eclipse forks when starting a Java application with either option. (I'm on a Windows 7 system)
With "Run HelloWorld"
.......
With "Debug HelloWorld"
(The address port changed in succeeding invocations, e.g. it became
address=localhost:2564
at the next invocation.)So java (or javaw) actually gets started with different options depending on whether "Run" or "Debug" was used: the "Debug" start-up adds an additional
agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:NNNN
option. This is a standard way of putting a JVM into debuggable mode. The HelloWorld program will first wait for its debugger to successfully connect to it before continuing (optionsuspend=y
). The HelloWorld JVM will connect itself automatically to some debugger running on address localhost:NNNN (... optionaddress=localhost:NNNN
and implicit default optionserver=n
). (... Oracle provides authoritative information on theagentlib
start-up options)Eclipse itself will act as the debugger application providing a port NNNN. The HelloWorld JVM will connect to this port, via its own port of number NNNN+1 (one can see a process's used ports with Process Explorer on that process's TCP/IP tab).