本文介绍了Java应用程序可以检测到调试器是否附加?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道(jvm)启动选项让jvm等待,直到调试器被连接 - 这不是我的意思。

I know about the (jvm) startup options to have the jvm wait until a debugger is attached - this is not what I mean here.

可以从在Java代码中还可以检测到调试器的附件,以便我可以例如写一个正在做某些事情的脚本,然后在某一点使我的应用程序等待调试器?

Is it possible from within Java code to also detect attachment of a debugger, so that I could e.g. write a "script" that is doing some stuff and then at a certain point make my app wait for the debugger?

推荐答案

否。这些选项是JVM选项,在调试器连接之前不会执行Javacode。然而,您可以让应用程序启动,并在一个变量上旋转一个变量,您可以从调试器中设置一个变量,让您的应用程序继续。

No. The options are JVM options, and no Javacode is executed before the debugger connects. You can however let the app start, and spinloop on a getter for a variable, which you set from the debugger to let your app continue.

这篇关于Java应用程序可以检测到调试器是否附加?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 10:34