{"id":743,"date":"2013-06-07T00:57:33","date_gmt":"2013-06-06T22:57:33","guid":{"rendered":"http:\/\/www.pellissier.co.za\/hermien\/?p=743"},"modified":"2013-06-12T09:47:24","modified_gmt":"2013-06-12T07:47:24","slug":"the-ultimate-netbeans-platform-resource","status":"publish","type":"post","link":"https:\/\/www.pellissier.co.za\/hermien\/?p=743","title":{"rendered":"The Ultimate NetBeans Platform Resource"},"content":{"rendered":"<p>Much has been written about the NetBeans Platform. But the ultimate resource still remains the source code of the Platform itself! I have used plenty of open source libraries over the years. And I have ventured into the source code numerous times. Quite often the experience is one that leaves one dazed and confused. But I have found that the NetBeans source code is well structured and easy to follow. So even on your very first adventure, you can gain much wisdom! \ud83d\ude42<\/p>\n<p>Reading source code is like reading a Physics text book. You can try to keep all of that information in your head, or you can experience it in practice. So in most cases, the easy way to find an answer is to debug into the source instead of just perusing it.<\/p>\n<p>How to set up the source code to be able to debug into it, depends on what type of project you are working with. For Ant-based module projects, download the source code of the same version as the platform that you are building on, and configure the platform to use it in the NetBeans Platform Manager (Tools &gt; NetBeans Platforms). This gives you access to all of the source code in all of the modules.<\/p>\n<p>For Maven-based projects, you have to attach the source code for each of the dependencies. In project view, right-click on one of the NetBeans module dependencies and choose Download Sources.<\/p>\n<p>Now put a breakpoint somewhere in your own module to start from. So for example, if you wanted to explorer the behaviour of the TopComponent class, put a breakpoint into the constructor of a TopComponent subclass (created using the Window wizard). And step into for example the setName() method.<\/p>\n<p>Using this methodology, you can explore how the platform loads and uses things like nodes and actions and windows. That will provide you with much deeper insight into how these things work!<\/p>\n<p>Robert Bracko (robert [dot] bracko [at] vip [dot] hr) explored the behaviour of an old third party IDE module from the 6.9.1 days. He sent me the following points, describing his fascinating first adventure!<\/p>\n<ol>\n<li>Downloaded NB 6.9.1 (Build Type: Release) from\u00a0<a href=\"https:\/\/netbeans.org\/downloads\/6.9.1\/zip.html\" target=\"_blank\">https:\/\/netbeans.org\/<wbr \/>downloads\/6.9.1\/zip.html<\/a>:\n<ol>\n<li><tt><tt>netbeans-6.9.1-201007282301-<\/tt><\/tt><wbr \/><tt>ml-javase.zip<\/tt>\u00a0(description: NetBeans 6.9.1 Java\u00a0SE OS Independent Zip\/English)<br \/>\nExtracted (not installed!) into directory\u00a0<tt><tt>netbeans-6.9.1-<\/tt><\/tt><wbr \/><tt>201007282301-ml-javase<\/tt><\/li>\n<li><tt><tt>netbeans-6.9.1-201007282301-<\/tt><\/tt><wbr \/><tt>src.zip<\/tt><br \/>\nExtracted into directory\u00a0<tt><tt>netbeans-6.9.1-<\/tt><\/tt><wbr \/><tt>201007282301-src<\/tt><\/li>\n<\/ol>\n<\/li>\n<li>Inside Development IDE (NB 7.3), added platform nb691 as new NB platform, based on directory\u00a0<tt><tt>netbeans-6.9.1-<\/tt><\/tt><wbr \/><tt><tt>201007282301-ml-javase\\<\/tt><\/tt><wbr \/><tt>netbeans<\/tt>.<br \/>\nSources linked for that platform, based on directory\u00a0<tt><tt>netbeans-6.9.1-<\/tt><\/tt><wbr \/><tt>201007282301-src<\/tt><br \/>\nSo far so good\u00a0\ud83d\ude42<\/li>\n<li>Project opened inside Development IDE: KoalaLayoutSupport. Project properties changed: NetBeans platform set to nb691<br \/>\nAttempt to build the project fails:<br \/>\nThe following error occurred while executing this line:<br \/>\nX:\\netbeans\\netbeans-6.9.1-<wbr \/>201007282301-ml-javase\\<wbr \/>netbeans\\harness\\testcoverage.<wbr \/>xml:22: C:\\Program Files\\NetBeans 7.3\\harness\\testcoverage\\<wbr \/>cobertura does not exist.What is strange here is that error message refers to\u00a0<tt>C:\\Program Files\\NetBeans 7.3<\/tt>\u00a0directory. Why does it look into NB 7.3 installation directory?<br \/>\nNext step was to investigate exactly what&#8217;s going on during build process. So I&#8217;ve selected project&#8217;s node Important Files &gt; Build Script and from the pop-up menu chose Debug Targer &gt; netbeans. I found out that file\u00a0<tt>nbproject\/build-impl.xml<\/tt>\u00a0<wbr \/>refers to file\u00a0<tt><tt>nbproject\/private\/<\/tt><\/tt><wbr \/><tt>platform-private.properties<\/tt>\u00a0<wbr \/>which further defines property\u00a0<tt>user.properties.file<\/tt>\u00a0<wbr \/>with value\u00a0<tt><tt>C:\\\\Documents and Settings\\\\Administrator\\\\<\/tt><\/tt><wbr \/><tt><tt>Application Data\\\\NetBeans\\\\7.3\\\\build.<\/tt><\/tt><wbr \/><tt>properties<\/tt>. Nothing wrong with that, right? Because at the same time debugger&#8217;s variables-window shows that property\u00a0<tt>nbplatform.active<\/tt>\u00a0<wbr \/>contains value\u00a0<tt>nb691<\/tt>, so the whole process of building should be (at least I think so) controlled by NB 6.9.1. platform.<br \/>\nBut then one suspicious thing:\u00a0<tt>build-impl.xml<\/tt>\u00a0tries to define the property\u00a0<tt>harness.dir<\/tt>\u00a0with value\u00a0<tt><tt>nbplatform.${nbplatform.<\/tt><\/tt><wbr \/><tt>active}.harness.dir<\/tt>. After having executed that line, debugger&#8217;s variables-window shows the value\u00a0<tt>C:\\Program Files\\NetBeans 7.3\/harness<\/tt>\u00a0for that variable! And that&#8217;s obviously wrong.<br \/>\nSo the next step was to change harness dir for platform nb691. I have done that through NB Platform Manager: inside tab Harness, choosing &#8220;Harness supplied with Platform&#8221; instead of &#8220;Harness supplied with IDE&#8221;. And then the build passed OK!\u00a0\ud83d\ude42<\/li>\n<li>Next thing, module debugging. Breakpoint set inside of module&#8217;s class works OK, also a breakpoint set inside of a class of NB 6.9.1 source. But&#8230; For the latter one, debugger&#8217;s variable window shows the error message &#8220;variable information not available,\u00a0source compiled without -g option&#8221;. I know what it means but how to resolve it?&#8230;.. For me it&#8217;s rather important to see how NB Form Editor source code interact with my module&#8230;<\/li>\n<\/ol>\n<p>Thanks for sharing, Robert! Some questions still remain unanswered in the steps above. Stay tuned for more about his next adventure!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Much has been written about the NetBeans Platform. But the ultimate resource still remains the source code of the Platform itself! I have used plenty of open source libraries over the years. And I have ventured into the source code numerous times. Quite often the experience is one that leaves one dazed and confused. But &#8230; <a title=\"The Ultimate NetBeans Platform Resource\" class=\"read-more\" href=\"https:\/\/www.pellissier.co.za\/hermien\/?p=743\" aria-label=\"More on The Ultimate NetBeans Platform Resource\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[3,5],"tags":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p1v8WL-bZ","_links":{"self":[{"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=\/wp\/v2\/posts\/743"}],"collection":[{"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=743"}],"version-history":[{"count":8,"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=\/wp\/v2\/posts\/743\/revisions"}],"predecessor-version":[{"id":748,"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=\/wp\/v2\/posts\/743\/revisions\/748"}],"wp:attachment":[{"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=743"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=743"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=743"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}