Before you can create a stack dump, you need to know (or find out) the process id of the application.
You can use the jps
command (or any other approach) to find the process for all running Java programs on the system.
e.g.
➜ jps
27566 Jps
27550 server.jar
In this case, 27550
is the process id of the app we're interested in.
The jstack
command "prints stack traces of all threads for a specified Java process".
It needs only one argument - the process id from step 1.
e.g.
➜ jstack 27550
2021-02-19 13:51:15
Full thread dump OpenJDK 64-Bit Server VM (11.0.9.1+1-LTS mixed mode):
Threads class SMR info:
_java_thread_list=0x000000016113e990, length=63, elements={
0x000000011f866000, 0x000000011f86b000, 0x000000011f886000, 0x000000012f905000,
0x0000000128808800, 0x0000000128809000, 0x000000012f80d000, 0x0000000129027000,
0x000000011f9d8000, 0x000000012f9c8800, 0x00000001284c5800, 0x00000001284c4000,
0x00000001284d4800, 0x00000001284d0800, 0x00000001284d1800, 0x000000014796d000,
0x000000012876a800, 0x0000000161851800, 0x000000016188b800, 0x00000001619ec000,
0x0000000147bc0800, 0x0000000147bbd000, 0x0000000161a60000, 0x000000011fb8a800,
0x0000000147a1f000, 0x000000011fb89000, 0x0000000147a2e000, 0x000000011fbd0800,
0x000000011fd0d000, 0x00000001280d7800, 0x0000000128791000, 0x000000011fd09000,
0x000000011fd0a000, 0x000000011f985800, 0x000000011f986800, 0x000000011f987000,
0x000000012d022000, 0x0000000161c56000, 0x00000001286d1800, 0x00000001280d9000,
0x0000000147e31800, 0x00000001286d4800, 0x00000001291e1800, 0x00000001286d5000,
0x0000000147e36000, 0x0000000147e36800, 0x000000012d00b800, 0x000000012d00c000,
0x000000014701b800, 0x000000011f98c800, 0x0000000147e91800, 0x00000001288bc000,
0x000000012d00d000, 0x0000000129141800, 0x0000000129142800, 0x000000012874a800,
0x000000012909c000, 0x00000001282dc000, 0x000000012e095000, 0x0000000129143800,
0x0000000128a42000, 0x00000001470c2800, 0x00000002d2393000
}
"Reference Handler" #2 daemon prio=10 os_prio=31 cpu=4.28ms elapsed=245.15s tid=0x000000011f866000 nid=0x4303 waiting on condition [0x000000016c97e000]
java.lang.Thread.State: RUNNABLE
at java.lang.ref.Reference.waitForReferencePendingList([email protected]/Native Method)
at java.lang.ref.Reference.processPendingReferences([email protected]/Reference.java:241)
at java.lang.ref.Reference$ReferenceHandler.run([email protected]/Reference.java:213)
...
:)