In a free-form project, you have to write your own Ant target to be able to profile the project. You generally want to write two targets in your freeform project's build script, one for profiling a project and one for profiling individual files. When you use the "Profile Main Project" or "Profile File" actions in the IDE, for the first time for a given freeform project as the main project, you will be asked to specify which Ant target to use.
The targets would typically look similar to your existing "run" target, with some additional parameters, so you may want to start with copying your "run" target into "profile" and modify it per instructions below.
You will need to make two changes in your profile target when you copy it from "run":
<jvmarg value="${profiler.info.jvmargs.agent}"/>
The following is an example of basic "profile" and "profile-single" targets (JDK 5.0 or later) for use in a J2SE project.
<target name="profile" depends="jar" description="Profile Project"> <fail unless="netbeans.home">This target can only run inside the NetBeans IDE.</fail> <nbprofiledirect> <classpath> <pathelement location="... specify ..."/> </classpath> </nbprofiledirect> <java ... use same attributes as with run ...> <jvmarg value="${profiler.info.jvmargs.agent}"/> </java> </target>
To start the profiler with a class selected in the explorer, you can add the same target, and use classname="${profile.class}". For example:
<target name="profile-single" depends="jar" description="Profile File"> <fail unless="netbeans.home">This target can only run inside the NetBeans IDE.</fail> <nbprofiledirect> <classpath> <pathelement location="... specify ..."/> </classpath> </nbprofiledirect> <java classname="${profile.class}" ... use same attributes as with run ...> <jvmarg value="${profiler.info.jvmargs.agent}"/> </java> </target>
Typically the server is started using a startup script, not the java command directly.
Therefore you cannot use the <jvmarg .../>
element to pass additional argument to it.
Instead, you have to modify the server startup script to configure it for profiling.
The recommended approach is to create a new script for starting the server for
profiling and use it in the profile
target.
The Attach wizard can generate the necessary modified startup script.
If your target server does not support automatic integration, you can
create the script manually by following the manual integration steps described in the wizard.
You always have to set up the integration for Local Direct attach.
The other steps for profiling a free-form web project are the same as those above for profiling a standard J2SE projects.
For more about how to profile a free-form project and arguments you can use, see the following NetBeans FAQ: