What is the best way to get a thread and heap dump of a Java process on Windows that’s not running in a console?

If jcmd doesn’t work for some reason, jmap is another option.

Just like before, find your PID using jps -l, then run:

jmap -dump:format=b,file=heapdump.hprof <pid>

This will generate the heap dump file that you can analyze.