How to Force Thread Dump in Eclipse?

2019-01-13 20:35发布

I'm launching a Weblogic application inside Eclipse via the BEA Weblogic Server v9.2 runtime environment. If this were running straight from the command-line, I'd do a ctrl-BREAK to force a thread dump. Is there a way to do it in Eclipse?

9条回答
我欲成王,谁敢阻挡
2楼-- · 2019-01-13 21:01

On linux at least you can do a ps -ef | grep java to get the PID and then do a kill -3 PID and it will output it to the Eclipse console.

查看更多
戒情不戒烟
3楼-- · 2019-01-13 21:04

Indeed (thanks VonC to point to the SO thread), Dustin, in a comment to his message, points to jstack.

I have run a little Java application (with GUI) in Eclipse, I can see the related javaw.exe in Windows' process manager and its PID, 7088 (it is even simpler in Unix, of course).

If I type at a command prompt jstack 7088, I have the wanted stack dump per thread.
Cool.

Would be better if we could do that directly from Eclipse, but that's already useful as is.

查看更多
Rolldiameter
4楼-- · 2019-01-13 21:07

StackTrace is another option that you could try. From the features:

Thread dump for Java processes running as a Windows service (like Tomcat, for example), started with javaw.exe, applets running inside any browser or JVMs embedded inside another process. StackTrace works on Windows, Linux and Mac OS X.

查看更多
祖国的老花朵
5楼-- · 2019-01-13 21:09

Eclipse Wiki: How to Report a Deadlock lists all possible options of creating a thread dump in Eclipse. Depending on the concrete situation, one or the other may work better -- my personal favorite on Windows is the Adaptj Stacktrace tool.

查看更多
手持菜刀,她持情操
6楼-- · 2019-01-13 21:13

Did you try to launch your eclipse with java.exe instead of javaw.exe (in your eclipse.ini) ?

That might give you the console you need, as described in this bug and in this message.

Other ideas (in term of java options) could be derived from this other SO question.

查看更多
神经病院院长
7楼-- · 2019-01-13 21:16

if you prefer UI based solution visualvm might be a good choice. (it's advantage is also that it's distributed with JDK)

To take the thread dump in visualvm:

  1. connect to process (remote or local) and
  2. go for Threads (tab) -> Thread Dump (button)
查看更多
登录 后发表回答