开发者

Java - How to programatically get a stack trace on a remote process

How can you, from a Java program, get a sta开发者_StackOverflow中文版ck trace on a known thread running in a remote VM?

Does the remote JVM need to be running with any special switches?


Do you really need to do this programatically from within Java (I guess so given that your question says so explicitly)?

Anyway, just incase not, then on Linux you can just do this on the command line:

kill -3 <pid>

EDIT: for programmatic access start the application with JMX enabled, connect to it via JMX and use ThreadMXBean.getThreadInfo to get a stack trace for each running thread.

If you have multiple JVM's on the same machine, each will need it's own distinct JMX port, you can handle this by repeatedly trying to select one from a pool, at random, and logging out the result.

See here for step by step on creating a custom JMX client.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜