{"id":433,"date":"2009-10-20T08:52:43","date_gmt":"2009-10-20T13:52:43","guid":{"rendered":"http:\/\/philippeadjiman.com\/blog\/?p=433"},"modified":"2025-07-19T19:34:54","modified_gmt":"2025-07-19T19:34:54","slug":"flexible-java-profiling-using-the-netbeans-profiler","status":"publish","type":"post","link":"https:\/\/philippeadjiman.com\/blog\/2009\/10\/20\/flexible-java-profiling-using-the-netbeans-profiler\/","title":{"rendered":"Flexible Java Profiling And Monitoring Using The Netbeans Profiler"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">I have tested a lot of those <a href=\"http:\/\/java-source.net\/open-source\/profilers\" target=\"_blank\" rel=\"noreferrer noopener\">open source profiler<\/a>. My preference goes definitely to the integrated Netbeans profiler. It was simply the easiest and unified solution adapted to all the different settings I ever met, including profiling java applications that <strong><em>(i)<\/em><\/strong> were not developed under netbeans <strong><em>(ii)<\/em><\/strong> were only in the form of standalone jar <em><strong>(iii)<\/strong><\/em> were running on a remote Linux machine for which no X server were running (i.e. no UI), and other cases.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here I describe how in 3 simple steps you can profile any java application using the wonderful Netbeans profiler.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 1: Download and install the latest Netbeans version on your machine(s)<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">On the <a href=\"http:\/\/www.netbeans.org\/downloads\/index.html\" target=\"_blank\" rel=\"noreferrer noopener\">netbeans download page<\/a> choose the version adapted for your environment (Windows,Linux,Solaris,Mac&#8230;) and download\/install it. All the bundles contain the profiler so I choose the lightest one: the JavaSE. If you want to profile a program running on a remote machine(s), you&#8217;ll have to download\/install it on each machine.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 2: Modify the command line that runs the java application that you want to profile\/monitor<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You just have to add an argument to the Java VM.<br>On windows, the argument to add is of the form:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"> -agentpath:\"C:Program FilesNetBeans 6.7.1profiler3libdeployedjdk16windowsprofilerinterface.dll\"=\"C:Program FilesNetBeans 6.7.1profiler3lib,5140\"<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Replace the portion &#8220;C:Program FilesNetBeans 6.7.1profiler3&#8221; by the correct path (located where you installed Netbeans). Keep 5140, it is the port on which the application will listen for a remote profiler session (that you can also perform locally, as in this tutorial).<br>On Linux, it is exactly the same, just look for the right path containing the profiler3 folder.<br>So the java command line of the application to profile should look something like:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">java -agentpath:\"C:Program FilesNetBeans 6.7.1profiler3libdeployedjdk16windowsprofilerinterface.dll\"=\"C:Program FilesNetBeans 6.7.1profiler3lib,5140\" MyApp param1 param2<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">When launching this command, you should see on your console a message saying:<br>Men, who are suffering from lesser sexual erection <a href=\"http:\/\/www.icks.org\/hugo33kim\/pdf\/PoliEcon222@HugoKim2015@02%20To%20the%20Readers.pdf\">viagra without prescription<\/a> problems, got magnificent results from this medicine. Avoid High Blood Pressure and High Cholesterol: Increased rate of STDs (sexually transmitted diseases) has been reported with Acupuncture in treating ED. <a href=\"http:\/\/icks.org\/n\/data\/ijks\/1482467285_add_file_2.pdf\">buy levitra discount<\/a> The treatment includes use of autologous bone marrow cells, which has shown symptomatic improvement in children along with improvements on radiological imaging purchase levitra <a href=\"http:\/\/icks.org\/n\/data\/ijks\/2010-1.pdf\">icks.org<\/a> studies. These firms are typically located in India where the patent legislation isn&#8217;t considered and these alternatives are typically provided on the web. generic cialis canada <a href=\"http:\/\/icks.org\/n\/data\/ijks\/1482457151_add_file_2.pdf\">icks.org<\/a>s 2 to 3 times more affordable when compared to the patented one. <em>Profiler Agent: Waiting for connection on port 5140 (Protocol version: 9)<\/em><br>meaning that the application is listening and waiting for a profiler session on port 5140.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Note the flexibility behind this approach<\/strong>: it allows you to add this simple argument to the exsiting command of <em><strong>(i)<\/strong><\/em> any java applications running inside eclipse (in that case just open the &#8220;Run configuration&#8221; windows, in the &#8220;Arguments&#8221; tab just add the -agentpath option in the &#8220;VM arguments&#8221; section) or other IDE than Netbeans, <em><strong>(ii)<\/strong><\/em> any remote java applications <em><strong>(iii)<\/strong><\/em> any standalone jar file, or whatever existing java command that runs any kind of java application you can imagine&#8230;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 3: Run the Netbeans profiler GUI<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Just open Netbeans, profile -&gt; attach profiler. Choose which kind of profiling\/monitoring you need, you can also configure it.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"1024\" height=\"670\" loading=\"lazy\" src=\"https:\/\/i0.wp.com\/philippeadjiman.com\/blog\/wp-content\/uploads\/2009\/10\/ScreenShot085.jpg?resize=1024%2C670&#038;ssl=1\" alt=\"\" class=\"wp-image-1995\" srcset=\"https:\/\/i0.wp.com\/philippeadjiman.com\/blog\/wp-content\/uploads\/2009\/10\/ScreenShot085.jpg?resize=1024%2C670&amp;ssl=1 1024w, https:\/\/i0.wp.com\/philippeadjiman.com\/blog\/wp-content\/uploads\/2009\/10\/ScreenShot085.jpg?resize=300%2C196&amp;ssl=1 300w, https:\/\/i0.wp.com\/philippeadjiman.com\/blog\/wp-content\/uploads\/2009\/10\/ScreenShot085.jpg?resize=768%2C503&amp;ssl=1 768w, https:\/\/i0.wp.com\/philippeadjiman.com\/blog\/wp-content\/uploads\/2009\/10\/ScreenShot085.jpg?w=1259&amp;ssl=1 1259w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Press Attach. Note that the first time you attach a profiler it may fail since you have to calibrate the profiler (in that case, a simple textbox will tell you how, it takes seconds).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That&#8217;s it!! You can now see in real time which part of your application is the heaviest, estimate what its memory footprint, analyze the threads and much more.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you want even more, note that it also exists specific profilers for collections (HashMap, HashSet, ArrayList, &#8230;) like <a href=\"http:\/\/www.collectionspy.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">collection spy<\/a> (not free).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>We&#8217;ll demonstrate NetBeans\u2019 built\u2011in profiler for low\u2011friction CPU\/memory profiling across Java applications.<\/p>\n","protected":false},"author":1,"featured_media":1995,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[11,17],"tags":[27,32,37],"class_list":["post-433","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","category-tutorial","tag-java","tag-profiling","tag-tutorial"],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/philippeadjiman.com\/blog\/wp-content\/uploads\/2009\/10\/ScreenShot085.jpg?fit=1259%2C824&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/philippeadjiman.com\/blog\/wp-json\/wp\/v2\/posts\/433","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/philippeadjiman.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/philippeadjiman.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/philippeadjiman.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/philippeadjiman.com\/blog\/wp-json\/wp\/v2\/comments?post=433"}],"version-history":[{"count":3,"href":"https:\/\/philippeadjiman.com\/blog\/wp-json\/wp\/v2\/posts\/433\/revisions"}],"predecessor-version":[{"id":1997,"href":"https:\/\/philippeadjiman.com\/blog\/wp-json\/wp\/v2\/posts\/433\/revisions\/1997"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/philippeadjiman.com\/blog\/wp-json\/wp\/v2\/media\/1995"}],"wp:attachment":[{"href":"https:\/\/philippeadjiman.com\/blog\/wp-json\/wp\/v2\/media?parent=433"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/philippeadjiman.com\/blog\/wp-json\/wp\/v2\/categories?post=433"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/philippeadjiman.com\/blog\/wp-json\/wp\/v2\/tags?post=433"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}