Profiling NetBeans platform application with YourKit Java Profile
Suppose we want to profile a NetBeans Platform application with YourKit Java Profiler, but installing the plugin is not an option, or because we do not want to add third-party plugins that can make the IDE unstable, or maybe we do not use an IDE at all.
At this point we have to do some manual configuration of our application ANT build file.
Open the main build.xml (the one of platform project to be clear) and add this ANT task:
<target name= "profileEclipse" description= "Lancia l'applicazione in debugging for Eclipse">
<property name = "debug.args" value = "-J-agentpath:<yourkit_installation_path>\win32\yjpagent.dll" />
<echo message= "debug.args=${debug.args}" />
<antcall target= "run">
<param name= "run.args" value= "${debug.args}" />
</ antcall>
</ target>
As you can guess we are simply using the standard NetBeans task to launch the application, we are simply adding the profiling configuration of YourKit agent.
At this point, since we can see the Java profiled process in the "Local Monitor Applications" of YourKit Console, we can click it and start the profiling session.
Obviously the same can be done directly on a Platform Application of which we only have the final distribution. Just open the configuration file in the etc directory, for example if the application is called "suite-test", then we must open the file <%PATH_TO_SUITE_TEST%\etc\suite-test.conf> and add the agent configuration:
# ${HOME} will be replaced by user home directory according to platform
default_userdir="${HOME}/.${APPNAME}/dev"
default_mac_userdir="${HOME}/Library/Application Support/${APPNAME}/dev"
# options used by the launcher by default, can be overridden by explicit
# command line switches
default_options="--branding suite1 -J-Xms24m -J-Xmx64m -J-agentpath:<yourkit_installation_path>\win32\yjpagent.dll"
# for development purposes you may wish to append: -J-Dnetbeans.logger.console=true -J-ea
# default location of JDK/JRE, can be overridden by using --jdkhome <dir> switch
#jdkhome="/path/to/jdk"
# clusters' paths separated by path.separator (semicolon on Windows, colon on Unices)
#extra_clusters=
Now running the application we can connect and profile it with YourKit.