Thursday, January 12, 2012


This page shows how to use InTrace to view remote JVM activity live on your Windows (or other linux/mac) desktop.


On the machine of the JVM you want to trace:
  1. Download this jar file to the machine with the JVM you want to trace. NOTE:  To work on IBM JVM's this jar needs a tiny MANIFEST.MF patch, detailed here
  2. Add this parameter to your JVM start-up parms, using the absolute path to the intrace-agent.jar file:  -javaagent:/home/myuser/intrace-agent.jar
  3. Restart the JVM.
On your Windows desktop:
    1. Download this InTrace jar file to your windows desktop.  
    2. Launch the UI with this jar file with "java -jar intrace-ui.jar"
    3. In the InTrace UI, click the "Connection" button to specify the host name/ip of the JVM to be traced.   Note that there is a default port (9123) that is used to connect.
    4. In the InTrace UI, click the "Classes" button to indicate which classes you want to trace/instrument.
InTrace is an open-source trace utility that lets you view live JVM activity in a window on your Windows desktop.  The activity of a JVM on remote machine (local too) is shipped via TCP back to your desktop live, as it happens.

What kind of JVM activity is traced?
  • Start/stop time of any/all method entry/exit
  • Values of all parameters passed into any method
  • Values returned from any method

To trace something, you first have to "instrument" it -- that just means you have to tell InTrace which classes you want to watch.  To avoid unnecessary overhead, InTrace only traces the class names that you specify.  There are two ways to instrument a class, so you can capture trace events from that class:
  • Start the InTrace UI and click on the "Classes" button.  See the "Installation" section, above, for how to start the UI.
  • Use Manual Instrumentation, below.
Optional Manual Instrumentation
Optionally, at JVM startup, you can specify the class names you want to instrument.  This is real helpful if you want to instrument the same set of classes every single time you start the JVM.

Say that you want to trace these three classes:
  • example.TraceExample
  • com.fis.Foobar
  • com.fis.HelloWorld
Use these java parameters on the JVM running the code you want to trace:


lali said...

This seems like a useful and simple to use tool. But, I have not been able to get my classes instrumented using Classes/Include/Add/Apply. Dump Settings seems to have the correct information (*** Settings:[out-stdout-false[gzip-false[trace-ee-true[exit-stack-trace-false[startwaitfalse[instru-true[out-file-false[exclude-regex-[verbose-false[[saveinstru-false[trace-args-true[trace-truncarrays-true[out-network-true[trace-branch-false

). Yet, Instrumented number of classes show 0!  I am connecting to a remote sever where the Java application is running.

Erik Ostermueller said...

Perhaps this is obvious, but the number of instrumented classes will remain at 0 until you exercise the class(TupleDataReflectionVisitor) yourself.

To rule out other weird possibilities (very complicated class loading), you might want to compile and run this simple command line program with the intrace-agent.jar.

Then do Classes/Include/Add/Apply with "example.TraceExample" ...and the trace data should come flying across the InTrace UI.