IDEA debugger to a running java process
是否可以将Intellij-IDEA调试器连接到正在运行的java进程?
Yes! Here is how you set it up.
Run Configuration
Create a Remote run configuration:
JVM Options
The configuration above provides three read-only fields. These are options that tell the JVM to open up port 5005 for remote debugging when running your application. Add the appropriate one to the JVM options of the application you are debugging. One way you might do this would be like so:
export JAVA_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"
But it depends on how your run your application. If you're not sure which of the three applies to you, start with the first and go down the list until you find the one that works.
You can change suspend=n
to suspend=y
to force your application to wait until you connect with IntelliJ before it starts up. This is helpful if the breakpoint you want to hit occurs on application startup.
Debug
Start your application as you would normally, then in IntelliJ select the new configuration and hit 'Debug'.
IntelliJ will connect to the JVM and initiate remote debugging.
You can now debug the application by adding breakpoints to your code where desired. The output of the application will still appear wherever it did before, but your breakpoints will hit in IntelliJ.
It's possible, but you have to add some JVM flags when you start your application.
You have to add remote debug configuration: Edit configuration -> Remote.
Then you'lll find in displayed dialog window parametrs that you have to add to program execution, like:
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
Then when your application is launched you can attach your debugger. If you want your application to wait until debugger is connected just change suspend flag to y ( suspend=y
)
另外,如果你想在调试模式下连接,不要忘记你需要在应用程序JAVA_OPTS中添加“-Xdebug”标志。
链接地址: http://www.djcxy.com/p/87846.html下一篇: IDEA调试器到运行的java进程