taT | Hacking Project Properties

Yesterday, I recreated one of the Visual Library Sample  (basically a tutorial based on it at Dzone) using NetBeans 6.7 IDE on Windows XP Professional SP2. The sample was Java Application that had two JAR’s (present in the platform7 cluster of NetBeans 6.0 IDE) in its classpath.

I followed the tutorial and successfully executed the application. Fortunately, I have NetBeans IDE from 5.5 onwards, so there wasn’t any issue finding the JAR’s and adding them in the application’s classpath.

I didn’t knew whether it will work with cluster from higher release or not. Hence, I decided to give it a try by making use of clusters from 6.1, 6.5 and finally, 6.7.

Playing Tricks..

Now, removing/adding JAR’s again and again can be boring/cumbersome if you have several releases stored under different hierarchies of your filesystem. So, I looked into the various files created under /nbproject to inspect how these JAR’s being referred.

When you right-click Libraries Node and click Add JAR/Folder..

right-click Libraries Node (Click to enlarge)

You’re prompted with the dialog for browsing and then, selecting Reference/Absolute Path as per your choice.

Browse to select platform7 cluster (Click to enlarge)

I selected the platform7 cluster (see above figure) and selected the JAR’s shown in the following figure.

Selected JARs from platform7 cluster

/nbproject/project.properties

This file contains all the project related properties, that are accessed by build-impl.xml (created from project.xml automatically) for necessary Ant operations.

file.reference.org-netbeans-api-visual.jar=\
  path\\to\\cluster\\modules\\org-netbeans-api-visual.jar
file.reference.org-openide-util.jar=\
  path\\to\\cluster\\lib\\org-openide-util.jar
includes=**
jar.compress=false
javac.classpath=\
 ${file.reference.org-openide-util.jar}:\
 ${file.reference.org-netbeans-api-visual.jar}:\
 ${libs.swing-layout.classpath}

The bold-faced text is added, once referenced JAR’s are added from Projects Window/Project Properties Wizard. Also, path\\to\\cluster refers to the directory where the platform cluster is stored. In case of the above application, here’s the path;

E:\\OpenSource\\NetBeans_Archies\\NetBeans 6.0\\platform7

Playing with Clusters

Now, as you can see the path\\to\\cluster is the same in this case. So, I introduce another property that will have the path as value.

path.to.cluster.platform=\
  E:\\OpenSource\\NetBeans_Archies\\NetBeans 6.0\\platform7
file.reference.org-netbeans-api-visual.jar=\
  ${path.to.cluster.platform}\\modules\\org-netbeans-api-visual.jar
file.reference.org-openide-util.jar=\
  ${path.to.cluster.platform}\\lib\\org-openide-util.jar

This way, the referenced JAR’s become dependent on this property. Now, one can also change the value of this property, i.e. if one is interested in using JAR’s from platform cluster of higher releases of the NetBeans IDE.

Then, NetBeans will automatically scan the project, to update dependencies. For instance, I opted for platform9 cluster from NetBeans 6.5 IDE.

path.to.cluster.platform=\
  E:\\OpenSource\\NetBeans 6.5\\platform9

I just made changes at one place, that will be automatically reflected in other properties that depend on it directly/indirectly.

Tips to Remember

However, you need to check your code, once you do these changes, as this might cause warnings on deprecated usage of certain API, when you build your application.

Also, if you do any error while editing your project.properties as for this scenario, or any other. You may end up seeing lots of error badges in your code and possibly, get an added menu item (Resolve Reference Problems..) in the project’s context menu.

Stay tuned..

Advertisements

Hyperlink Navigation Renaissance | #2

Last year, I had written a blog on Hyperlink Navigation Renaissance, here’s brief overview;

After lot of discussion on OpenIDE mailing lists, exploring Developer FAQ’s, exerting my wrist, flexing fingers and what not? Finally, hit the deck hard! Yeah, Hyperlink Navigation in NetBeans got smarter! Especially, for HTML documents.

That time, I had developed a plug in, which I have started to discuss about more these days. Yes, its Revamped Hyperlink Navigation and here are list of blogs discussing about it;

These blogs basically describe the history of this plug in, pointers to available resources at Kenai and how do I use SVN for managing the plug in source code from CLI, as well as from NetBeans IDE.

Now, I would like to tell you that there has been many changes since and I thought community would be interested to see the updates in the tutorial, I wrote last year. Have a look at this wiki for updates, rather than the entry at NetBeans Zone (If you want to, then see the comments for updates).

Changes done..

I have got rid of overloaded setPosition methods, instead there would be one method from now onwards. While, some of the methods were renamed and some are no longer parameterized. This has reduced lot of redundant code and now, the code looks really neat. Making use of various editor features to cut-short long line of codes has helped.

Also, I removed the parameterized constructor, instead introduced a public method to pass necessary parameters from HyperlinkProvider implementation. This was done so as to possibly introduce an interface, which the module would depend on, while its implementation is available in another module. Yes, I am trying to make use of Lookup API to achieve same result.

Only issues I have, that currently one module can only depend on another user-defined module within a suite project. However, module I created is standalone one and its not possible to depend on another module, AFAIK. If you know of ways to do so, let me know or join this project to work towards achieving this.

NetBeans 6.7 and Manage Platforms..

All of this was possible due to a feature I recently discovered in NetBeans 6.7 IDE, which was there in previous releases as well. However, I never really explored it. By the way, NetBeans 6.7 FCS is released. Check out the new, super cool homepage of NetBeans DOT org.

NetBeans 6.7 FCS released!

Stay tuned..