Setting up the Profile Project Command for a General Java Application


If you have the NetBeans Profiler installed, you can use it to profile free-form projects. (See Chapter 15 for more information on installing and using the Net-Beans Profiler.)

In order for the Profile Main Project command to work with a free-form project, you must add an Ant target to your project's build.xml file. This Ant target will be very similar to the target you use to run your application, with some additional tasks and parameters. The minimum changes are:

  • A call to the custom nbprofiledirect task, with a parameter that specifies your application's CLASSPATH.

  • An extra argument to the java task to specify a JVM that supports profiling (${profiler.info.jvm}).

  • An extra JVM argument that signals the JVM that it is being profiled (${profiler.info.jvmargs.agent}).

For this example run target

     <target name="run" description="Runs my Application"          depends="compile, init">          <java jar="myApplication.jar"              fork="true">          </java>      </target>


the profiling target would be

   <target name="profile" description="Profiles my Application"        depends="compile, init">          <nbprofiledirect>              <classpath>              <pathelement location="myApplication.jar"/>              </classpath>          </nbprofiledirect>          <java jar="myApplication.jar"              fork="true" jvm="${profiler.info.jvm}">              <jvmarg value="${profiler.info.jvmargs.agent}"/>          </java>    </target>


After you add the target, select Profile | Profile Main Project. The IDE will prompt you for the target that should be used for profiling.



NetBeans IDE Field Guide(c) Developing Desktop, Web, Enterprise, and Mobile Applications
NetBeans IDE Field Guide(c) Developing Desktop, Web, Enterprise, and Mobile Applications
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 279

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net