I frequently showcase the jhat, jps, and jstack tool set to developers on Linux and Mac. However, a developer recently indicated that these are unusable in Windows if the Java app in question is running as a Windows Service.
A Sun-filed bug says something very similar, but was closed due to inactivity.
I have tested this out for myself, and indeed it appears true, though I can hardly believe it. Here is the setup:
This appears reproducible under Windows XP, Windows 2003 Server, and Windows 7. Java versions 1.5 and 1.6 yield the same outcome.
Is there a way from the terminal, even though logged in as Admin, to "sudo up" to get JPS and the other tools to see the java service?
To get the utilities to run, you can connect to the Console session using "mstsc /admin" using a login account (not sure exact permissions it needs to have, mine was in the Administrators group) and use the Sysinternals psexec tool to run as system. Here is an example of using jstack.exe:
psexec -s "%JAVA_HOME%\bin\jstack.exe" PID >stack.txt
Where PID is the process ID of your process. You may also have to substitute the actual path to your JDK depending upon your specific environment.
Also, the TEMP directory must be set correctly or once again the tools will not work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With