You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 16 Next »

Netbeans Setup

If you don't have Netbeans on your machine already, download and install it.

Next, install the Netbeans Maven plugin.

Under Tools -> Plugins -> Available Plugins, check the box next to Maven. Click Install.

Now open LCSim by selecting Open Project and clicking on the LCSim root directory.

You should see LCSim in your Netbeans project window now.

Setup the Profiler

The profiler needs to be calibrated before it can be used. Select Profiler -> Advanced Commands -> Run Profiler Calibration.

Some information is required to connect the profiler to our application.

Select Profiler -> Attach Profiler to pull up the Attach Profiler window.

Click on the Change link at the bottom of the window to bring up the Attach Wizard.

Make sure Local and Direct are selected. Click the Next button twice.

Copy and paste the entire string beginning with "-agentpath" to a local scratch file. This will be needed to connect the running code to the profiler.

Setup LCSim

Right click on LCSim and select Set as Main Project.

Right click on LCSim again and select Properties.

A new action will be created for running the code with profiling. Select Add Custom. Name the new action "Run Profile".

Copy the Execute Goals field from the Run project action.

Paste the string you saved earlier into the Set Properties field. Then put the string "netbeans.jar.run.params=" in front of it, with no space in between.

The custom action should now look something like this.

The profiler connection string will be different depending on where Netbeans was installed.

Create a Main

We are almost ready to run the profiler. One technicality is that the profiler will only run on classes that have a main routine.

I created a class called ProfilingTest in the package org.lcsim. Technically, this class could be called anything and could be located anywhere under the src directory in lcsim.

Add a main routine to this class with some test code. Here is my version of ProfilingTest.java.

package org.lcsim;

public class ProfilingTest 
{
    public static void main(String args[])
    {
        System.out.println("hello profiler");
    }
}

This class needs to be designated as the project's main run class.

Right-click on the LCSim project, select Properties and go to the Run window. Enter the fully qualified name of your class in the Main Class field.

Theoretically, the profiler connection information would go into Arguments and VM Options. But there appears to be a bug where this information is not saved properly, so we leave them blank.

Connecting to the Profiler

Run the test code by right clicking on the LCSim project and selecting the custom goal Run Profile under Custom.

  • No labels