Running btrace on a short running program from NetBeans

321 Views Asked by At

I wanted to run btrace on a short running program from NetBeans so I started jvisualvm from a Window command prompt then started the program in debug mode from NetBeans and set a breakpoint on the first statement in the "main" class.. I then right-clicked the program from the visualvm Applications window and selected "Trace application". Then I selected continue on netbeans to run the program and the output of the btrace was created on visual VM. Is this the easiest way to run a btrace session on a quick program from NetBeans?

1

There are 1 best solutions below

1
On

Using VisualVM to generate a trace of short running applications does not seem to be optimal. You would be better of with a CLI approach.

  1. Pre-compile the BTrace script using btracec
  2. Create a new project configuration in NetBeans and add the following VM options
    • -javaagent:<path-to-btrace-agent.jar>=stdout=true,script=<path-to-compiled-script>
  3. Select this configuration and run the application to obtain the tracing output from stdout