There was a requirement to get a thread dump on a Windows server running an app with JRE. There are many things to think about
- If you use a JDK, you can get it normally, but if you have a JRE, jstack does not exist, so you need to install a JDK?
- Can you get a thread dump of an application running on JRE with a JDK installed on a different path?
- You have to run the application on JDK?
- Leave JRE as is and install additional JDK? You have to be careful about Path
- JRE and JDK must match ver
Since I don’t know various things, I wonder what kind of error message I got for trial, download a suitable JDK and try jstack on a suitable Java application. I thought, but I do not have a suitable Java application, so I remember that Eclipse is running in Java, and try Eclipse (eclipse.exe) as a trial
(I got a thread dump) ↑ Wrong usage of headline (I wanted to make it big, but it’s a pity that this is the only method)
I have no idea what eclipse.exe is and what kind of Java runtime environment it is. jstack is appropriate but works at all Even if the path or ver is different between jstack and java to be acquired, it’s ok
Next, verify it assuming that it will be acquired in production.
- On the internal server where the application is running with JRE
- Download and install the same ver JDK
- Get thread dump for JRE application through path to JDK at command prompt
This is also OK
Let’s go further and try to copy and execute only jstack.exe and the library
- Copy jstack.exe from JDK bin to JRE bin
- Copy tools.jar of JDK lib to JRE lib
- Get thread dump to the application running on JRE with jstack copied to JRE bin
java.util.ServiceConfigurationError: com.sun.tools.attach.spi.AttachProvider: Provider sun.tools.attach.WindowsAttachProvider could not be instantiated 1548: no providers installed
(I’m sorry, I wrote that I was able to do it in the first post, but I tried again later and it was no good)
So, although it is necessary to install JDK, I found that jstack can easily take a thread dump even with a JRE partner.
- In the first place, I should use the JDK from the beginning..
- This is the only command
jstack -l <PID>
- I got this error if I didn’t place tools.jar -There was a tool if lib was scolded by the message here, so I put it and proceeded to the next (Miscellaneous)
Error: Main class sun.tools.jstack.JStack was not found or could not be loaded