Sunday, 13 April 2008

Portable NetBeans - part II

Of course just placing NetBeans on USB drive and running it from there doesn't make it really portable. Why?
As most of the serious contemporary applications the IDE uses some deal of system awareness. That means it not only scans the host system (during installation) for where your Java is but it also takes account on the user's home directory, where the service information have to be stored.
So when the installer is started, if you monitor the contents of your user's directory in Windows, you'll see a new one created - '.nbi'. It stores the logs and configurations that let the installer, when started again, know what exactly have been installed on the previous occasions(s). That's not bad at all. On one hand you have a host environment that may serve you as a dock for your portable IDE. But on the other, it restricts the portability. This folder may be moved on the USB drive, but NetBeans installer will still search for it in the current user's home directory. That's not a catastrophe so far - you successfully installed the IDE already and most probably it won't happen again up till the next version.
Anyway, another and more important directory is created into the user's home the first time NetBeans is started - '.netbeans'. This is the actual configuration center for the IDE - updates are downloaded here, the current state of the application is preserved here, etc. In time this folder may become quite big in size. What's worse - this directory could leave a trace of your presence on the host system! Oops! That would be so unportable.
I feared so, that's why I made a test. I ran the IDE on a fellow's laptop. Before that I had been moved the '.netbeans' folder in a place such as 'X:\tools\netbeans\conf' on my USB memory. When started the update center I expected the '.netbeans' folder to be regenerated into the user's home. Nothing like this. I installed a module and the trace for this was written exactly where it had to be - in '
X:\tools\netbeans\conf\.netbeans\6.1\update-tracking' and the module was downloaded into 'X:\tools\netbeans\conf\.netbeans\6.1\modules'. It is still a mystery to me how this happened, because it is dumb to believe that things happen this way. On a second try it didn't work. Of course.
So, what is the right way? Well, I just opened the right file: 'X:\PortableApps\NetBeans 6.1\etc\netbeans.conf' and provided the correct value to the
netbeans_default_userdir variable on the second line:

Now with everything in place NetBeans starts and updates very portably.
Yet another 'prankster' always appears during the NetBeans startup - the '.netbeans-registration' directory. It regenerates anytime, anywhere. And always leaves a trace. It isn't much - just a small XML status file, but this is a trace after all. I don't mind to register my IDE, but no more than once is appropriate, I think.

Well, all these 'hacks' are just on the go. We can hardly ever expect an official version of Portable NetBeans from the community or SUN. If you're smart enough (and I bet you are) and you chase the Portable conditions then the sky is the limit, like they say. Not only the IDE but the Java itself can alway be made thinner and slimmer and encapsulated. It is only a matter of little effort and plenty of free time. And of course limitless imagination.

Thursday, 10 April 2008

NetBeans 6.1 & MySQL

As we all know few months ago SUN Microsystems acquired MySQL AB - the vendor of (still) the most popular open source database server. Did this make an impact on the SUN's preferred JAVA IDE? Well the answer is easily noticeable when comparing the 6.0 and the 6.1 (still Beta and still evaluating) versions. In the 'Services' tab of the IDE there's always been a 'Databases' node introducing set of supported JDBC drivers and predefined connections. Since JAVA 6 (and consequently NetBeans 6.0) the JavaDB (also known as Apache-Derby) was presented and strongly supported with its Embedded and Network drivers. Defining connections through drivers for MySQL and PostgreSQL database servers was also supported.
Now in the 6.1 version we see much stronger support for JavaDB and MySQL. They're separated in their own database nodes, which has enhanced controls over the server management and properties.

The extended administration support lets you redefine the default start and stop commands for the server with custom arguments. Once defined the right way those commands are available in the MySQL node's context menu.
It also makes possible in the 'Admin Properties' to choose any MySQL aware application as additional administration tool - not only the vendor's applications from the GUI tools package, but really any Windows application.

Once connected to a Schema on the MySQL server, you may expand the connection icon and three folders are available, for the three major database objects supported by MySQL - Tables, Views and Procedures.
NetBeans is a powerful database editor, supporting creation and management of databases and their objects by comfortable specialized dialogs or just by executing SQL scripts in the code editor.
Quick table creation is available through this dialog:

It looks easy and really is. If this is not sophisticated enough for you, just choose 'Execute command ...' option from the context menu. A text editing window opens, where you can describe in SQL any table structure you like.
Maybe the most advanced feature is the 'Design Query ...' window (available in the context menu of the table's columns. Its visual approach makes creating complex queries more intuitive and fast.

In the end it might be stated that creating Java database-driven applications with MySQL back-end have always been non-trivial task, involving different tools. Applications for database administration and query design; for schema design and entity relationship management. Let's not forget the IDE for code creation. Now with the 6.1 version of NetBeans the control shifts toward one single tool - the IDE itself. This could help the developer be more focused and shorten the completion time for their project, no matter if it is in Java, Ruby or C++.
I think this is a good start and in the future versions the MySQL support and database support as a whole will be enhanced further. With such excellent UML designer one might expect that ERD for databases will also be supported.
So whatever course might be taken from now on in the MySQL-NetBeans community, the results will be expected with great impatience from me. Good Luck!