how to use strace with java

Apparently strace doesn’t play well by default with java.
strace -p pid doesn’t work, for example.

This does, though [follows forks--why necessary, dunno].
You can start it under strace:
$ strace -F -f java Readfiles # where Readfiles.class exists

or (for an already running process)

$ strace -F -p <pid>

ref: http://publib.boulder.ibm.com/infocenter/javasdk/v6r0/index.jsp?topic=/com.ibm.java.doc.diagnostics.60/html/linux_tools.html

2 thoughts on “how to use strace with java

  1. Are you sure about this? I’ve found that you can simply use JPS to get the proc id and then use that as the input to strace:

    jjj# JPS
    20524 xxxxxx.jar

    jjj# strace -o /tmp/output -f -r -p 20524

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>