Search code examples
javadebuggingjarexecution

Get the current stacktrace of a java program while it's running


Suppose I ran a java program using the java command, is it possible to get the current position or stacktrace of the this program while it is running if I have the source code of that program? A solution which does not stop my program is preferred.


Solution

  • jps to find the process id. jstack to dump the stack.

    If it is running for the command line the ctrl-Z/ctrl-break (depending on platform) will also do the job.