Monday, 14 December 2009

NetBeans' native portability


I bring up the theme of portability once again, because of the last comment from this my post. Thanks on this Valery! I really missed this one before.
Let us start with the obvious - Java is by default a portable language. So any software written in it, if not making any assumptions for the host operating system or utilizing platform specific features, should without changes run anywhere. Although the NetBeans IDE is developed with several OSes in mind, it also has such platform-independent version:

As can be seen, the most complete bundle for the current version (6.8) lacks the JavaFX IDE and the application servers, but has everything else.

Download, unzip to the USB drive (lets say we have K:\netbeans folder as a result) and this is where the fun begins.
In the K:\netbeans\bin folder there are two files - a Windows executable, and a shell script for the UNIX family OSes. All is the way it should be.
Running the netbeans.exe on different PCs shows that the IDE feels pretty comfortable anywhere. It even isn't as slow as I expected! The only "drawback" is that it makes itself at home everywhere. This means that it scans the local $HOME directory and arranges its properties there. It even suggests you to import the setting of a previous version if such has existed on the machine. I'm still not sure how this gets along with installing your preferred plugins on the PC and then using them on another PC. But I wouldn't rely on such IDE scattered across several computers. I just would take the steps necessary to make it more portable. The step is generally one and it is toward editing the K:\netbeans\etc\netbeans.conf file. This configuration file is pretty self explanatory but lets take a look just in case.
The first property is netbeans_default_userdir. Its default value is "${HOME}/.netbeans/6.8". At first I replaced it with:
"${HOME}/.netbeans/6.8" -> "../.netbeans/6.8"
and ... nothing actually happened. In such cases running the executable makes things a bit more clear and ... it did:

It appears that the NetBeans IDE doesn't let you place its configuration and properties directory into its installation directory. That makes sense if think about it. So pick some place on your USB drive dedicated to configuration stuff and point to it in the netbeans.conf file. In the end I have my specific properties in K:\data\.netbeans\6.8 and it works fine with the property value set to:
netbeans_default_userdir="../../data/.netbeans/6.8"
The second property is netbeans_default_options. Its default value tunes up the JVM that runs the IDE with several parameters. They are not directly relevant to the portability. They are more of a performance tweaks.

All the other properties are commented, hence not taken into account by the IDE. Here's what they mean:
  • netbeans_jdkhome - this one is important and it should be uncommented in all cases where on the host OS there is no any Java installed. It also must be uncommented for the sake of portability. In my case I have this path K:\jdk\jdk1.6.0_16. I could put it in the K:\netbeans folder but I also use portable eclipse in some cases, so the JDK is kind of shared between the two IDEs (and any Java dependent software I decide to use on my USB drive in future). The value for the property becomes "../../jdk/jdk1.6.0_16" (that makes two folder up in the tree).
  • netbeans_extraclusters - this is related to modules that come separated from the official bundles. For example you've made your own C# editor on top of the NetBeans platform and you want to use it in your portable IDE. This is where you set the relationship between both.
Well, if I have some conclusion to make, it would be that if the intricacies of the host operating system are not concerned, the portability is only a matter of correctly setting the paths, whatever your portable media is.

So far we've exhausted the current portability issue, wright? Wrong! What about UNIX/Linux? And what about WINE? Soon.
Post a Comment