Friday, July 13, 2007

Maven projects with NetBeans IDE (Part 1)

(This article is on google docs too).

Introduction

I'll present here how to use Maven projects with NetBeans IDE via the MevenIDE project. Since the emphasis is on Maven and Maven-support, I'll just play the devil's advocate and try to focus on most of Maven's features while also underlining ant's flaws.


As always, the answer is somewhere in the middle. There are cases where ant is preferred to Maven and some when it's the other way around.


The build system

All NetBeans projects are ant-based. Ant is a very useful tool due to the cross-platform and usually easy to write build-scripts. But these scripts to compile, generate, build and deploy the projects usually endup being quite complex.


They are so complex sometimes that they represent basically another part of the project. They are also non-standard for each project (especially legacy free-form projects).


Now, using the IDE, we have some pre-cooked scripts and special ant-tasks. But your build-system is rather tied now to the IDE (not actually to the IDE, but to those ant-tasks). Everything is open-source, true, but you can't actually just take the official ant distribution and build your system... You need to tweak it a little. (In NetBeans' defense, at least you have a ready-made ant build system. With other IDEs, you just have some metadata but nothing usable outside the IDE.)


Is it a bird, is it a plane ? It's Maven

Maven isn't an ant replacement. It includes a build-system component, but it's something else. It provides a consistent view on any project with a standardized project definition and plugins for reports and website generation. Think of it as a general project management tool that includes a build tool.


Basically with Maven you don't write any scripts ! Maven provides you a standardized way to structure your project and you just configure various build / reports / site plugins. Therefore you don't have any build scripts anymore -- you have a declarative description of your project, called POM (Project Object Model).


Maven also introduces the concept of repository. That is, a place where all the build artifacts (the resulting JARs or WAR/EAR files) are saved and retrieved from. For example it's easy to imagine a setup where the whole team uses a read-only repository with the 3rd party artifacts. Thus, they don't need to sit in the VCS !


I really can't sum it up better than that so I recommend using the Maven website to learn some more.


MevenIDE

The Maven-NetBeans IDE integration is provided by (part of) the MevenIDE project (install it from here).


All my examples are based on NetBeans 5.5. Sadly, with the NetBeans 6.0 release approaching, most of the Maven-integration work is being put there. That is, for the NetBeans 5.5 version MevenIDE is somewhat beta quality and you're supposed to have more luck with NetBeans 6.0 (now at milestone 10).


You might stumble onto some bugs for the 5.5 integration but it's a very dynamic project with people still working on it and it's quite easy to find workarounds or help in the mailing lists (Milos Kleint is usually there to help).


So, if you don't actually like living on the bleeding-edge by either using the current Maven integration for NetBeans 5.5 or by switching to NetBeans 6.0 M10, you're out of luck. But my advice it to take a chance ! It will be worth it.


Java Application Project

Let's see how you could use a Maven project instead of a normal Java Application Project.


After you created a new Java Application project with the NetBeans wizard, you should have in the Files view something like:


/src

/test

/nbproject

build.xml

manifest.mf


(The Files tab should be next to the Projects tab).


Now we select File->New Project and then Maven2->Archetypes project with the Quickstart Project template. Artifact Id is a public name for your project (for example: maven-javaapp) while Group Id is usually your company (com.example). Please note the “version” parameter. You'll find this useful with dependencies:




Both wizards create some files and some example classes. The NetBeans-default Java Application creates a Main.java file but no test. There are also a lot of semi-exotic files in nbproject/ .


The Maven wizard creates a pom.xml file and a src/ folder. The pom.xml file is the project-metadata for Maven. It basically replaces the build.xml and nbproject/ . It is not the only metadata file Maven uses, but it's the only one that's mandatory (and the one you usually see).


The project name

After you've created the Maven project, you'll see that the name is something like "Maven Quick Start Archetype (jar)". Of course we need to change that to match the default IDE style (which I'm trying to duplicate so far). So, we open the Project POM file in "Project files" and look for the <name> element. Just editing that to "Java Application" and saving the POM should be enough, the Maven Project from the "Projects" tab will refresh and you'll see the new name. Pretty nice, no ?




Please note the extra "Project profiles" file in there. As I told you, there may be some other metadata files, but for most actions, the POM is king.


That was a forced introduction in hand-editing the pom.xml file. You might as well have used the Project properties window to edit the project name. This will automatically change the POM file.



You will notice that the MevenIDE plugin has some pretty nice support for the metadata files. You have auto-completion in the POM file not only for the XML schema but also for plugins from the local repository. There's also hyperlink support (just hold the Control key pressed) that not only opens a browser for real URLs but is able to jump into modules and parent projects (this is a feature of Maven we're not going to talk in this article, but it's good to keep in mind).


Running

Since we already have the Source and Test folder, the main action we'll be doing is running a main-class.


First, if you select Run via Run->Run Main Project menu or the F6 key you'll see this warning message:


It basically tells us the the NetBeans-Maven bridge isn't configured yet, so it doesn't know what to run. As the message says, right-click the project and go to Properties.


We configure the Run->Main Class to something like "com.example.App" (or whatever your package is).


Now, if you open the POM again you'll see that a whole lot of data was automatically added under some <profiles> element.


Again, you select to Run this project (right-click on the Project -> Run or just press F6 if it's the main project). After some messages in the output window, you'll see something like this:


BUILD ERROR (Badly configured, need existing jar at ...)


Huh? What was that ??


Well, as I've said, bugs do exist and you've just stumbled upon MEVENIDE bug 485 . Luckily, there is a workaround: just open the POM and look for

<plugin>

<artifactid>maven-assembly-plugin</artifactid>

then add

<version>2.1</version>


What does this do ? Well, Maven uses various plugins to run everything from building to creating the JARs, to generating reports. Each plugin has a version so we can still have old projects working. Now, where do you expect all these plugins to sit ? Of course -- in the Maven repository.


Whenever a plugin isn't found, Maven tries each repository in order to download it (by default there's only one repository, the official Maven repository).


So, in our case, MevenIDE was using the latest maven-assembly-plugin from the repository which is in beta and has some issues. By forcing the version on 2.1, everything works.


Take note that I've said "download it" above. You should expect something like "Downloading maven-assembly-plugin" with a progress bar in the lower-right corner.


Testing

If you like writing tests (don't you ?), just use right-click on the Project -> Test . You'll see the details in the output window. If everything is ok you should see a BUILD SUCCESSFUL. If some tests fail, you have a BUILD FAILURE and you may click on the failed tests in the output window to see the stacktrace:


MevenIDE also has nice support for the output with marked stacktraces just like the standard projects.

Debugging

In order to debug a project, right-click it in the “Projects” tab and click Debug or just select Run->Debug Main Project (the F5 key). It should look the same as the IDE-project.

Are your tests failing ?

Maven is really in love with tests and these are so important that they break the whole build. That is, you cannot run or debug a project if one of your test fails. This does make sense in theory, but in practice you always have some tests that fail (at least I do ;-) ).


The workaround is to skip tests. From the IDE, you just go to the project properties -> Action Mappings and tick “Skip tests” for the action you want (Run project, Debug project or both).


If you run Maven from the terminal, you must add “-Dmaven.test.skip=true”.


If you feel really in shape, you can configure in your POM the plugin that's in charge for tests and just exclude the tests you are still working on. Just add something like this and you're done:


<project>
<!-- .... -->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<exclude>**/TestBroken1.java</exclude>
<exclude>**/TestStillFailing2.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<!-- ... -->
</project>

Note the already familiar artifactId and groupId for the plugin configuration.


This is the end of part 1. Stay tuned for the next articles about how to use dependencies, how to configure your own repository, how to make EJB/EAR artifacts and even NetBeans Platform modules.

I feel like Windows98 again

I've been having some Windows98 flashbacks ever since I'm using Ubuntu 6.06 on a Dell C840.

There are various reasons: resume kills the sound system, sometimes the ethernet and once in a while corrupts the video (easily fixed by ctrl+alt+F1 ctr+alt+F7). The expected hardware support problems under Linux.

Since I've installed Google Desktop Linux I also had for a while sudden Firefox crashes (fixed by disabling their extension). Boy was that fun ! Not to mention Firefox 1.5 doesn't save the session (make sure to install the SessionSaver extension).

The latest culprit is OpenOffice.org. Usually it works ok, but then you have the random crash. It's nice to have a Crash Recovery dialog and all, but I would rather not see that as often. It also has the tendency (usually after some crash recovery) to not start at all. You just click on and odt file and wait... and wait.. and nothing. You click again: and wait ...

The solution is usually a restart (so un-linuxy).

But, all in all, it's a usable desktop that kind-of forces you to do something productive since it's so simple. With no fancy GUI to drool at, you're forced to think and work. Or, post in your blog about how productive you could be.

Thursday, July 05, 2007

Google Desktop for Linux crashes Firefox 1.5 on Ubuntu 6.06 (Dapper Drake)

I've installed Google Desktop Linux on my Ubuntu 6.06 system and found that Firefox crashes a lot ! And by a lot I mean I couldn't even google for advice ;)

Basically after some log hunting I found out the cause is quite simple: the Google Desktop for Firefox extension is broken.

Just go to Tools->Extensions,right-click Google Desktop Firefox and select Disable.

That seems to be it ! Happy google indexing.

I recommend you also comment on the bug-report here (posted on Ubuntu's Launchpad.net).

Wednesday, June 27, 2007

Maven and NetBeans (Platform)

As most of you know, the build system in the NetBeans IDE is entirely ANT-centric. That is, every project has a generated build.xml behind the scenes and every action (compile, run) is an ant target actually.

But, of course, you can't please everyone. Using ANT as a backend means that, of course, you need some custom ant targets to make the IDE-integration better. Thus, you're not 100% independent of NetBeans, you still need those custom tasks (some JARs basically) and the core ant scripts.

Using ANT also means some overhead for each action.

But the most nasty stuff in my projects are the 3rd party JARs. Most projects use some outside blobs. Normally, you can have the JARs in SVN and NetBeans will take care of this quite nicely (using relative paths).

But what happens if you decide not to include those JARs in the SVN ? Well, you enter a world of tweaking of .properties files and custom ant tasks to re-populate those properties files. It's not pretty and error-prone in a distributed project.

Maven on the other side has this repository concept. That is, a place where some 3rd party JARs sit. Your POM file (project metadata basically) just declares the dependencies and the repository list.

Imagine that: you have a local intranet repository and everyone in the team is using it. No more relative paths, no more custom ant tasks !

I've been migrating my SVN for about 3 weeks over to maven. I have normal Java projects, Enterprise projects (EJB/WAR) and NetBeans Platform modules (NBM). It's a bumpy road (I haven't used maven until now) but it does seem to simplify thigs.

But what you win on the dependency side you lose on the integration part. With MevenIDE you have normal NetBeans IDE projects, but not that kind of IDE-integration you have to module-projects for example. No more easy configuration for public-packages -- back to editing manifest files like in the old NetBeans 3.x times ;-)

Overall, Maven2 seems a better choice for the build backend then Ant. You can't customize it that much but once you have all the plugins properly configured, it works better. Plus that you are totally decoupled from the IDE and IDE tasks, but you depend now on the extra plugins.

Most of the continuous integration servers offer support for Maven2 projects so you can drop the new projects immediately.

Monday, June 18, 2007

Gnome Typing Break

As I've said in an older post, I wasn't that impressed with the latest Ubuntu but I also couldn't install OpenSolaris on a laptop. So I installed Ubuntu 6.06 LTS, which seems to work quite nicely. I even has suspend to RAM working (though it breaks the sound afterwards).

One nice feature Gnome has that I didn't know of it is Typing Break, found in System -> Preferences -> Keyboard.


It basically forces you to take a break after a period of time. Gets useful after you start getting some hand-aches. During the break you see something like this:



It takes a bit of discipline to actually respect the breaks (especially when something is urgent and you have the "Postpone" button -- which should be renamed to Snooze). Then again, even if I disable the postpone button I might be tempted to Ctrl+Alt+Backspace or Ctrl+Alt+F1, login then kill process.

I'm also looking at some exotic and ergo- keyboards lately. Anyone has something to recommend ?

I would really like something like 2 half-keyboards. One for each hand, then going into the USB port. This way I can place them to the right and left side of the laptop and use them quite nicely -- it's almost impossible to use an external keyboard with a laptop without also adding an external display.

OK, no flying cars. But 2007 and no mind-reading input devices ? Someone is slacking off...

Thursday, June 07, 2007

Pro NetBeans IDE 5.5 Enterprise Edition Review

Adam Myatt's "Pro NetBeans IDE 5.5 Enterprise Edition" could be quite well an introductory course to Enterprise programming in general and especially a good book for NetBeans IDE (future) users in particular.

It's quite decent for a novice programmer because it consists of small tutorials and introductions in all the different technologies that the NetBeans IDE supports. It gives you the starting point in your endeavor. It's most needed for an introductory course in any Enterprise since it touches a lot of important points like unit-test, good javadoc, version control, build system (ant-centric, like the IDE) and more.

Since it covers that many topics there isn't actually enough space to go too deep into any of the subjects. The spotlight is after all on the NetBeans IDE and the features it has. This is quite a shame since there were some unique things that could have been discussed more upon: Jackpot refactorings made me really curious...

It's also nice to see some features I've discovered myself in the IDE after a while - like the database support and SQL command window - which turned out to be quite useful. Readers get a chance to find out about them from the start.

All in all, a good book that covers a lot of ground. It doesn't touch at all making NetBeans Platform modules, but that's not expected for a NetBeans IDE user. Although, after a while of living in your own IDE, you can't help it but customize it a little -- enter module development.

Wednesday, June 06, 2007

There is truth

There is truth, my boy. But the doctrine you desire, absolute, perfect dogma that alone provides wisdom, does not exist. Nor should you long for a perfect doctrine, my friend. Rather, you should long for the perfection of yourself. The deity is within you, not in ideas and books. Truth is lived, not taught.
Herman Hesse, The Glass Bead Game

Tuesday, June 05, 2007

OpenOffice and Java take 2

Hm, I just got this morning the weekly NetBeans newsletter and it had this part:

Netbeans Plugin for OpenOffice.org Development

Sun's OpenOffice.org engineering team has developed a plug-in for building OpenOffice.org extensions. It is an easy to use set of wizards to create OpenOffice.org extensions that can be used to integrate new functionality, adopt existing functionality, and create Java applications that can remotely control OpenOffice.org. Everything is ready for you to start implementing OpenOffice.org extensions, including a Java code skeleton.

So, SUN is still supporting this. Maybe I'll take a look at this new plugin and see how it feels.

Monday, June 04, 2007

Is OpenOffice too late with the Java-bindings ?

I remember my first "important" job at my previous employer was to maintain some in-house Office-based application. Nothing like Excel and VBA to ruin your day ! Well, I was a rookie so I couldn't refuse but it was a depressing experience.

For some time now (I remember I was running some samples last year), OpenOffice has some nice Java bindings (or API). Now, this is all great, but the actual code looks quite arcane.

What troubles me is this: why was OpenOffice so late with this move ? I mean, most programmers don't want to live inside Excel and Visual Basic so if you have a choice, you move a simple dedicated "application" from Excel + VBA to OpenOffice + Java.

I guess it's obvious Java is a better choice (than VB) for most programmers (it would have been for me) and the final product would have been better in so many ways:
  • More happy programmers that they don't have to use VB or (oh, the horror), maintain VBA.
  • A decent codebase for your initial small application in Java, that could, potentially be migrated to a full Swing application (if we just treat OpenOffice Calc or Write as the GUI toolkit). I mean, most code will get thrown away anyhow, but it's quite a waste of time reimplementing the same business logic (with the VB code as a reference). This would be a perfect change to actually use the IDE's refactoring.
  • Possible introduction of OpenOffice in the corporate ! Sure, people would still copy-paste from your "application" into Microsoft Excel but that should be quite pain-less. But the developer won't have to worry about a new Office version or some other Microsoft-specific (DLL) nightmares.
But, today, making desktop applications with OpenOffice (in the same style like Excel + VBA + VB DLLs) seems less of an option:
  • it's really hard (look at the API) and the practice isn't actually encouraged. The 100% Java purity had probably done more wrong than right here and most people will just suggest using some Swing Application or framework like NetBeans Platform. But why shouldn't people do this kind of applications ? Most internal apps have some sort of tabular data and lists and then fancy reports. Why should we struggle with JasperReports and such when you have the nice OpenOffice Writer codebase ? Export to PDF: check, export to tons of other formats : sure!
  • OpenOffice doesn't provide a nice "platform". Something to put in a folder with all the jars and DLLs and work flawlessly. I don't need to "install" OpenOffice: I just want to distribute my application as a simple ZIP file. No DLL hell, no nothing. Make that with (Consumer) JRE included and a simpler API ! (this is linked to the previous point).
  • We have reached the point where tiny web-apps seem good enough and are developed fast enough to give existing Excel-based tools a short lifespan. This is a good way because we get rid of Excel but people still need to reinvent the same things over and over: charts and nice (PDF) reports that OO Calc should have facilitated (do I hear OpenOffice-based rich-client ?).
I think OpenOffice missed the boat by a lot for standalone (tabular) applications and it would have been a really nice thing for everyone ! Maybe even for Microsoft since it would have put to death the abomination known as VB 6.

Sure, this would have destroyed the purity of your application, mixing it with the OpenOffice native code and maybe even with some other COMs but I think it would have been better overall.

Wednesday, May 23, 2007

Euro ripoff (aka The gold you have to pay for pretty glass in Romania / Timisoara)

Ever since the dollar took a nose dive against the Euro I always drooled at the nice prices the US seems to have. Why ? Because most sellers in the EU (and Romania) make a really 1:1 conversion. This means that if something is about 1000 USD in the US it will be about 1000 EUR in EU (although this means about 1300 USD - 30% increase! ).

Now, on the other side of the spectrum sits Romania. Since we basically have no market-culture and we are still in some sort of Wild-wild-west kind of economy, the prices here are even higher than in the EU. So, there you are: probably in the poorest country among the EU ones, and you have the biggest prices for computers.

That would be one thing but there's more: you basically can't find decent brand workstations (powerfull desktops) and if you do, your best chance is if you live in Bucharest, the capital. And Bucharest is way in the east compared to Timisoara, and quite-ugly as a city might I add ;-)

So, outside Bucharest you only have the major retailers (which means that you get no service on-site and all your hardware is sent to Bucharest for service; scary thought for a laptop) or some medium-sized companies. As in Economy 101, when you sell something that's in short supply, what do you do ? Well, of course, you increase prices.

Thus the local companies that do have service on-site have even higher prices than the retailers.

In summary: Price(Timisoara) > Price(Bucharest) > Price(EU) >>>>> Price(US).

To everyone that complains in the US about high Apple/HP prices or some other nonsense like this I have an advice: come to Romania for a while and live the experience :-)

End of trolling / muble-grumble session.

Saturday, May 19, 2007

Migrating to Derby (JavaDB) with schema

I went to a lot of trouble lately trying to migrate a database from MS SQL Server to Derby (aka JavaDB) [1]. I've used the DDLUtils ant tasks to export-import the database.

The major issue was that in my previous database we used a given schema and that schema wasn't recreated now by DDLUtils. I've tried tweaking the ant task parameters but still nothing. I even done some quick sed scripts [2] to add the schema myself (rename tables from "oldname" to "schema.oldname" basically). But all this meant nothing. Plus that the database was 100MB+ and import time was well over an hour so I couldn't actually try a lot of times.

The solution resided in the Derby FAQ but it wasn't until someone from the mailing list pointed it to me that it struck me:
The current schema for any connection defaults to a schema corresponding to the user name.
You see, I was creating the database beforehand with some random user like "admin". I didn't notice this was the default schema. Also, while reading the same FAQ, I just skipped to the part with SQL.

So: if you migrate to Derby, always create an username with the same name as your schema (the one you import).


--
1. I wouldn't actually put Derby on a production server but I feel better during development having the data in a more cross-platform DBMS . Plus, I'm spared of all the security issues MS SQL has (or at least my fear of having those ports open).

2. Yep, sed. I know some XSLT might have been smarter but I'm quite rusty at that and there is no easy xslt shell/script I could use.

Friday, May 11, 2007

Building is fun with Hudson

I've used last year Cruise Control and really liked the feeling a continuous integration and build system gives you. There you have a central place to see the health of the project (unit tests), linked to the VCS and a build server.

This year, I've re-evaluated Continuum and Cruise Control and found out that I still had to work with some XML files to make it work. Plus, notification is exceptionally hard to get right.

So, everything was paused until I found Hudson. It's a web-application (like the other two), quite new and active (unlike the other two).

It has the best out-of-the-box experience. Just deploy the WAR and configure your project. Continuum comes close here with Cruise Control third.

Since NetBeans already generates proper ant targets for everything including tests, I just need to configure what ant task to run, which are the build artifacts and where to get the junit results from.

Of course, I did stumble on some problems:
- Running multiple ant targets it's impossible (ie. multiple build files) so you have to make another script that calls the others.
- make sure junit.jar is in ant's classpath.

But Hudson is impressive. Help messages at each step, SVN integration (with authentication), nice charts.

It could still use some more reports and plugins but I think it has a bright future. I might even write some plugins myself if it gets selected for the build-server.

Monday, May 07, 2007

Still in OS land: OpenSolaris

After Ubuntu, I said I could give a chance to (Open)Solaris. I do remember Solaris from the Sparc stations we had at the University and I keep on reading about ZFS and dtrace, but I never actually used it much.

So I just went and downloaded the DVD, burned it then installed Solaris with no fuss on top of the previous Ubuntu partition. Rebooted the system and it all worked! Even had an option to switch between Gnome and CDE -- well that brings back memories...

First, OpenSolaris (Developer version) really seems a Java programmer's kit: I get NetBeans 5.5 with Sun Java Application Server. Even the installer seems Java. Plus, I have Firefox, Thunderbird and a Terminal: that about covers most of the stuff you actually need while working. Sadly, no movie player like Xine or VLC.

Of course, there was some strangeness:
  • it also installs Sun One Studio which seems redundant with NetBeans but I didn't actually try it.
  • even if we do have SJAS installed, it doesn't show up in NetBeans. Using the Server Manager is quite easy to add it and it took me about 3 minutes but it was strange. I guess it has something to do with the multi-user settings.
So, wish me luck. I kept wanting to try out SJAS clustering and doing this under Solaris seems the best solution.

Friday, April 20, 2007

Ubuntu 7.04 over-hyped

I've used Linux under some form or another for some time (I think 7 years or so). Started with some SUSE then found out RedHat and switched to Ubuntu when Fedora turned out to be a mess.

Since I'm a little stuck on Windows for the programming part I use nowadays mostly Windows (2000/XP) and OSX.

Ok, so I saw all the hype about Ubuntu 7.04 and downloaded the torrent. Let's say I wasn't impressed.

I used a lot at my previous job Ubuntu on a T60 Thinkpad so I knew how it should feel. This new release was about the same plus a fancy-er splash screen.

Even more, the Live-CD detected my NVidia Quadro NVS graphics card and installed the driver for it. Thus I could enable "Desktop Effects" and look at the wobbly window (then disable it immediately).

Ok, so I've installed 7.04. The first surprise: it didn't boot-up ! I mean, it did, but in text mode.

You know why ? The XOrg configuration still had the reference to the nvidia driver but the installer didn't actually install the driver on the hard-drive. Since this is something common (to me), I just went to xorg.conf, and replaced the driver with the default nv. I only assume a normal user would have given up at this point with no GUI.

Ok, with nv I'm able to startx and install the nvidia driver (plus some update manager ... update). I need to restart the system (why ?) because of the new driver.

Again, it doesn't boot ! Why ? I have some wacom input devices in my xorg.conf and it fails while looking for the device (/dev/wacom or something).

Again, I edit xorg.conf, comment those things and -- finally ! -- I'm able to boot normally.

The nice thing is that I'm able to install Sun's JDK immediately. When I get to Netbeans in Synaptic I notice a warning that that package doesn't actually contain Netbeans, I have to manually download the tar. The package Netbeans from Synaptic just provides "integration" with Gnome. Huh ?

So, this is the first Ubuntu that crashes on me at install time and basically forces me to go inside config files. If anything, I would say it's a regression and not an evolution.

One could say that it's my graphics's card fault, but since Ubuntu does provide the users nice point-n-click ways to install those drivers, anyone would expect for those things to work.

Thus, I'm still waiting on my Windows/OSX setup with the intention of buying another Mac as soon as Leopard comes out.

Friday, January 12, 2007

NetBeans Platform: CallbackSystemAction sync madness

An annoying problem I had this week involved the CallbackSystemAction class.

Basically the general ideea of this type of action is this: you have the Action implementation, but the "#actionPerformed code" is deferred.

What was my problem: depending on the user selection in an explorer, my action was supposed to become enabled or not (plus some othe conditions).

So, the javadoc says that way to do it is by setting an action in the ActionMap of the TopComponent.

TopComponent tc = ...;
javax.swing.Action yourCopyAction = ...; // the action to invoke instead of Copy

CopyAction globalCopyAction = SystemAction.get (CopyAction.class);
Object key = globalCopyAction.getActionMapKey(); // key is a special value defined by all CallbackSystemActions

// and finally:
tc.getActionMap ().put (key, yourCopyAction);


The problem is that there is no listener on the action map. So if I want later to disable my action and I do a tc.getActionMap().remove(key) -- it won't work ! I mean, it will work if you change the current TopComponent and come back to the original (I guess there are some event thrown there that CallbackSystemAction catches and does a refresh).

So, using the ActionMap.put and #remove doesn't work !

Ok, I said to myself, I'll just use the deprecated #setActionPerformer , which seems to work better. Only it is deprecated, which is not good.

I went and complained on the dev@openide mailing list and I got a tip that I should change my TopComponent's lookup in order to fire the events that CallbackSystemAction might catch to refresh itself.

But you can't call #associateLookup twice ! Arr.

So I just started reading carefully the CallbackSystemAction source code and I've noticed that it does put a listener on the enabled/disable state of the TopComponent's action (ie. yourCopyAction in the example above).

So -- what's the solution ? Dead simple: call getActionMap().put(...) once and then just do a #setEnabled on your Action. Simple -- but very non-intuitive.

Actually in this situation I would say that the Javadoc was more confusing than useful because it says

The action will be automatically disabled when it has no performer.

and removing your action from the ActionMap means exactly that: no performer...

Saturday, January 06, 2007

NetBeans Platform: Combobox in property editor

Happy new year everyone !

I'm going to talk today about something simple GUI-wise but quite a lot asked on the mailing lists: how does one display a combobox in the property editor ? Actually, how does one use an editor that displays a combobox.

What should get you started with this task (and other editor customizing) is a little file from the Platform javadoc.

This is what we plan to get:


In order to do this note the Custom parameters in core editors paragraph from the above link and the fact that for java.lang.Integer properties there are some custom keys we can use:
  • stringKeys - an array of strings to be present in the combobox
  • intValues - an array of integers representing the values of the selection in the combobox.
So something like this:

Node.Property p=new YourProperty(Integer.class);
p.setValue("intValues",new int[]{1,2,3,4});
p.setValue("stringKeys",new String[]{"One","Two","Three","Four"});

is all you need.



Note: Please take care that for the current property
  • #getValue is the index in the intValues array. So if you want to see "Three" in the combobox, you return the number 2 in #getValue.
  • #setValue is called with the actual number from intValues (not the index). So if the user selects "Four" from the combobox, #setValue(4) will be called.

Friday, December 15, 2006

NetBeans Platform: Carefull with Matisse and FocusTraversalPolicy (aka Focus subsystem)

Matisse is a really nice GUI editor. But it doesn't seem to be quite up-to-date with the Java Focus Subsystem.

JComponent.setNextFocusableComponent() is deprecated since 1.4 ! And yet, this is all Matisse has to offer.

The right way to specify focus cycles since 1.4 is via FocusTraversalPolicy. You just set Container.setFocusCycleRoot(true) and then install your FocusTraversalPolicy subclass.

The problem is that setNextFocusableComponent has priority over the focus policy:

Overrides the default FocusTraversalPolicy for this JComponent's focus traversal cycle by unconditionally setting the specified Component as the next Component in the cycle, and this JComponent as the specified Component's previous Component in the cycle. (quote from Javadoc, emphasys mine).

So, if you try to define in Matisse some focus cycle the old fashion way (the only way possible right now) but then you want to use a FocusTraversalPolicy you have to go back and remove all the nextComponents otherwise it will break everything !

My advice: don't use nextFocusable on Matisse ! Do it by hand with FocusTraversalPolicy and wait for the 6.0 release when this should be fixed.

Thursday, December 14, 2006

NetBeans Platform: Watch out for the Platform security !

I always had the impression that the Platform is quite lax security-wise. Since you have in the Lookup the system ClassLoader it's not like they can restrict your module that much.

Well, I was a little mistaken. Apparently they do add some security checks.

And a particularly strange one is a security check on System.exit().

Actually, it makes sense to restrict calls to System.exit() but the way I've discovered it is surprising: I just moved a JFrame (made with Matisse) from the Java app to the platform. And by default, JFrames, have EXIT_ON_CLOSE set.

Well, on the Platform, the JFrame won't even show up ! Why ? Because of the EXIT_ON_CLOSE property. It eventually boils down to something like:

SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkExit(0);
}

which fails inside the platform with an org.netbeans.ExitSecurityException .

So the problem is that initComponents() throws this unchecked exception so the entire new Frame().setVisible(true) call fails. Even more: this doesn't show up in the logs!

Btw, System.exit() works just fine during ModuleInstall. It's LifecycleManager that breaks down at that (early) point.

Monday, December 11, 2006

NetBeans Platform: Node.Property custom editor

The property window is a nice quick way to let the user view and edit some values. It's not recommended as a valid approach (one should make its own windows) but it is quick. Just provide some activated nodes, open the Properties windows and all the declared PropertySets will be visible.

The nice part is that we already have a lot of predefined PropertyEditors for boolean/integer/string/font/color/date values.

But if one of the editors doesn't please us, just use Node.Property.getPropertyEditor() .

For example if we need a different date format, it would boil down to a new class:


class DatePropertyEditor extends PropertyEditorSupport{
private SimpleDateFormat sdf=new SimpleDateFormat("yyyy/mm/dd");

public String getAsText(){
if(getValue()==null){
return "";
}else{
return sdf.format((Date)getValue());
}
}
}


We just return a new instance of this class in getPropertyEditor() and that's it.

This gets a little more complicated if you actually need to edit the value as you have to provide a custom editor component but for simple read-only properties, this is all there is !

Wednesday, December 06, 2006

NetBeans Platform: 1st NetBeans Platform workshop in Timisoara. Make that in Romania

Today was the first NetBeans Platform workshop and presentation in Timisoara, held by your's truly. I'm also about certain it's the first in Romania too.

My ex-employer had this Java-workshop about various subjects (Struts, MVC, Hibernate, Design Patterns, Swing and NetBeans (Platform) ).

The presentation was quite nice. There were few people but with many questions (yeah, I'm looking at you Dan ! ).

I had a small OpenOffice presentation as the starting point and in the end I worked only in the NetBeans IDE, showing off:
I only remembered I had a camera at the end of all the discussions. I was too bussy answering questions ;)


I'll try and post another picture with the NetBeans powerpoint in the background later on today or tomorrow. Of you could just download the presentation together with the small application written on the spot.

UPDATE(11.dec.2006): New photos on Flickr.

Tuesday, December 05, 2006

NetBeans Platform: TopComponentGroup strangeness

Ok, I never used window groups as I wasn't that used to have that many interdependent windows.

It seems easier to add a "Palette" inside your JPanel and it surely is easier to handle than to make a separate window tha listens on the Lookup/activated nodes and reacts.

TopComponentGroup seems like the next logical step: if you already started using a whole bunch of windows that are interconnected somehow put them in the same group.

The teoretical advantage would be that
1. You get to easily open and close the whole group. You don't even have to know *who* is in the group. (Note the nice decoupling you get there).

2. The Group implementation remembers the closed/open state of contained TopComponents and restores them in the same way. This makes it consistent with the user.

Well, it's number 2 that annoys the hell out of me. For example: what if I *don't* want to remember the state ? What if I have 3 TopComponents that work together but they should *always* be in an open() state together ?

What do you do then ? Of course: do it manually. You lose the decoupling and have to keep hard references to your "buddy"-windows and .open() or .close() them by hand when needed.

Which means that by this point TopComponentGroup is useless and you might as well remove all the code/xmls. Grr.

Wednesday, November 22, 2006

NetBeans Platform: Lookup.Result garbage collection trick and active TopComponent lookup

In the old days, one could listen on changes in the "activated nodes" of the active TopComponent with a listener on TopComponent.Registry paying attention to the PROP_ACTIVATED_NODES property.

Now Lookup is a much nicer way to show activate "objects". The way to listen globally to
changes in the Lookup of the active TopComponent is via Utilities.actionsGlobalContext() (which is a Lookup itself).

The trick is simple, you add a LookupListener on the Lookup.Result you get from Utilities.actionsGlobalContext().lookup(yourLookupTemplete) .

What is the garbage collection trick ?

Well, it's quite odd for me the existence of the Lookup.Result class. Because you don't do something like Lookup.addLookupListener(yourLookupTemplate, yourLookupListener). If you were to do something like this, you would expect that your listener lives as much as the Lookup. Meaning in the case of a "global" listener -- forever.

But what you do do is actually add a listener on Lookup.Result, which could be garbage collected and thus your listener also.

Generally, keep a hard reference on the Lookup.Result (or make a closure on it with some final keyword and a reference from the anonymous listener). Because if you don't -- the garbage collector might kick in quite soon and your listener won't be called.

Monday, November 20, 2006

NetBeans Platform: Branded resources

OK, you've probably been here too: how does one load a Branded resource ? Let's say... the splash screen.

Well, let me tell you the stages you might try after you've found out that it's "org/netbeans/core/startup/splash.gif" :
  • Use the ClassLoader from Lookup to load the resource. What does this do ? It returns the default, non-branded splash.
  • getClass().getResource(). Same as above.
  • new URL(). Wrong !
  • Utilities.loadImage(string). Still wrong.
Of course, the nbres:// protocol might also help (after all it's a NetBeans resource we're talking about) but you know what ? It also fails (with NPE) except for the new URL method.

So ? What is the solution ? Well, it's Utilities.loadImage(string, true) . This is the only one that does the localized/branded woodoo. I'm still not certain why the nbres:// stuff didn't work...

Sunday, September 24, 2006

Busy blogless month

It has been a really busy month since the last time I've blogged about the NetBeans Platform (or anything else).

Mainly it consisted of:

* one week holiday
* another super-busy week at work trying to do a quick catch-up for an urgent (aren't they all ?) project
* another week working and being part-time sick
* another week still recovering and starting to remember the Platform.

Basically my MindMapping application isn't near as ready as I would have liked (and there is at least another person working on the same thing: MindMapping with Visual library + NetBeans Platform). Bug it will be ready when it's ready. No deadline here. I was thinking maybe also use the new-ish StarOffice integration with NB that I kept reading about.

The good news is that I'll be working more on NetBeans Platform-related tasks so watch out for new hints.

I've also received a new Mac Mini (well, PPC actually not the new Core Duo) so I've got myself some new display/keyboard too ! A whole bunch of new stuff to make me want develop.

BTW: forgot to mention I've also got an article on the netbeans.org website. That was quite an interesting experience ! (you should see the blog traffic spike :) ).

Wednesday, August 23, 2006

NetBeans Platform: StatusLineElementProvider order and Progress bar

Using the nice META-INF/service, one can declare it's own little status-bar piece by implementing StatusLineElementProvider . You basically just return your Component that will be placed on that IDE/Platform status bar.

What the javadoc for StatusLineElementProvider doesn't say is how does one define the order for the components in the status bar.

Well, since we are using the services, then Lookup has something to do with this. Indeed, the documentation states this and also mentiones two other Lookup features (aka extensions): you can remove service implementations and you can define the order they are returned. Of course, this order is used for StatusLineElementProvider too !

So, just edit the org.openide.awt.StatusLineElementProvider file and add after the implementation class name something like #position=10 to define a position for your implementation.

At Platform startup these will be instantiated starting with the smallest position and going up.

Another thing: the Progress API line element has position number -13. So, if you use -14, -15 for 2 fake items, you get something like this:



If you use bigger numbers you get something like this:



And, I could also get rid of the progress bar altogether with

#-org.netbeans.progress.module.ProgressVisualizerProvider

Enjoy.

If this was helpful for you then maybe you'll like reading the other NetBeans Platform-related posts.

--
Emilian Bold
Java-loving consulting services from Timisoara, Romania.

NetBeans Platform: Showing Progress to the user

The Progress API is a new (I've noticed it in the 5.0 release) and usefull little API. It has a rather simple task: display to the user the Progress of long tasks.

Usually it makes sense to use it if you have a task that may run in the background. If you need to block the whole IDE I guess you need to do it in a modal dialog-way.

But most of the long tasks may safely run in the background. With Progress API you just declare your new task and then in the lower-right part of the main window you'll see a progress bar.

Usually you have two kinds of tasks: tasks execute a predetermined number of steps and you could estimate something like a percentage realised so far and tasks that could go on for ever.

The fun part about the Progress API is not only that it allows you to have *determinate* and *indeterminate* kind of progress handles (this is how your little presenter is called) but it also allows you to switch between determinate and indeterminate tasks.

Imagine this: you take a locally-saved HTML file and need to re-save it with links up to a depth. For all local links you pretty much know it's going to take little time to copy the file so you have a determined progress (with a percentage shown) but once you start downloading something from the net you have no ideea how much it will take. So you switch to indeterminate and the user sees just an indefinite progress bar.

Even better, you could have more than one task running at one point. So if you click on the progress bar for the current task, a popup will appear with all the tasks.

Did I mention tasks could be canceled ? Yeap, you could declare that too and a small "close" button will appear next to the progress bar. Really handly.

Now, if you need this for standalone non-Platform based apps, you might find https://progress-api.dev.java.net/ usefull. There is one app where I used it and it works great !

On holiday during the 24 august - 31 september period.

--
Emilian Bold
http://emilian-bold.blogspot.com/

Java and NetBeans Platform-loving consulting services from Timisoara, Romania.

Tuesday, August 22, 2006

NetBeans Platform: Options Dialog isValid() or implement thy TODOs

The Options Dialog API allows an invalid state for the panels.This is normal, it could happen that user changes lead to an invalid state and you don't want to set some magic default. So, you force the user to make all the changes until the panel is in a valid state.

For example: I have an user that may be a minor. If he's a minor, the parent's name must be set. I have 3 situations:

  • he's an adult. Panel state is valid. Ok and cancel button are active, no warning. All is good.
  • he's an minor with an empty parent name. You get the red text warning (which is just Swing from my JPanel, no Platform stuff here) and the OK button is disabled. Noticed that ? This is where the isValid() does its work.
  • he is a minor with a non-empty parent name. The OK button is enabled (isValid contribution) and no more red warnings (pure Swing code): Fun stuff no ?



The way this is doable is: just look at the TODOs.

  1. Implement the load() and store() methods in the generated Panel to have persistence.
  2. Implement the valid() method in the Panel. In my case is something as simple as
     return adult || (!adult && parentName.getText().trim().length()>0);


  3. Then implement the final TODO from the constructor: listen to changes in form fields and call controller.changed() In my case I just call controller.changed() when the radio buttons are pressed and also in a DocumentListener for the text (to detect if the parent name changes and provide instant feedback).



And that was all it was needed. Now I have a simple, interractive with possible invalid states option panel.

If this was helpful for you then maybe you'll like reading the other NetBeans Platform-related posts.

--
Emilian Bold
Java-loving consulting services from Timisoara, Romania.

Monday, August 21, 2006

NetBeans Platform: Branding the help with layer kung-fu

Since I said that I have to make a proper application and I was too lazy to actually write any complicated code in the weekend I said: ok, let's add the Help. If you're new to NetBeans Platform, this means basically that there is a Wizard to generate a whole bunch of files and configuration: the Java Help-related files and the files to have the integration with the Help system of the Platform.

Since NetBeans 5.5 this Help Wizard has been a real life saver. The was too much wodoo going on there to actually get it done by hand. It was doable just no something you do when you want to feel relaxed.

The deal about the Help System it's that, of course, is designed to take into account the situation where you have multiple modules with their own helpset. But when you develop a standalone platform application you only have one helpset and you get this ugly picture first:
As you see there is an annoying first page.

The nice thing about the NetBeans Platform and IDE is that the sources are available so you can always grep the hell out of them and find what you need. For example, it seems that this page is in core/javahelp (unsurprisingly) and that it's named masterHelpPage, referenced from the masterHelpMap.jhm with MASTER_ID . MASTER_ID pops up in master-help.xml (based on helpcontext-1_0.dtd) which has an option showmaster = true / false. So this must be the guilty thing.

Ok, there it is, but how does one change it ?

Indeed, found the (possible) culprit. So I have to change the showmaster somehow. Since I've always felt that Java Help is unnecessary complex, I first assume I have to patch the build system and modify the damn file. Nasty but doable.

But this looks like some sort of per-application customization, known as branding on the NetBeans Platform. Branding is the same process that lets you change the application splash screen, icon, title, Bundles for localization and more.

And branding usually involves work with the Bundles, the layer.xml file and new resources (icons, etc).

Since I can't possibly imagine how one could brand, I find on the net Geertjan's blog topic on the subject. The solution is unbelivebly short:


<folder name="Menu">
<folder name="Help">
<file name="master-help.xml_hidden"/>
<file name="your-master.xml" url="master.xml">
</folder>
</folder>


Read Geertjan's post for more details.

Layer kung-fu

The ideea is simple: all layers on the Platform are placed on a stack with your module's layer on top. So basically you can't only add or hide (with _hidden) new files, but you can also replace them.

Of course ! This is how branding gets done.

So in the XML above you see the existing master-help.xml file is hidden and then replaced by our own (where we set our own MASTER_ID). It's so simple I can't believe it.

I always though the layer ideea was a little over-engineered but now I'm a believer.

Layers: I know kung-fu!
Developer: Show me !

If this was helpful for you then maybe you'll like reading the other NetBeans Platform-related posts.

--
Emilian Bold
Java-loving consulting services from Timisoara, Romania.

Saturday, August 19, 2006

NetBeans Platform: Who needs the Web Browser ?

During my lobby period for the NetBeans Platform at my workplace I did
with a coleague a quick port to the NetBeans Platform of a Swing application.
Of course, nothing too Platform-dependent, just module with
TopComponents instead of JFrames, library wrappers, etc.

Now, one of the complaints was: "hell, in another tab I had a *web browser* !"

Tonight I was looking at the new NetBeans 6.0 M2 Platform and it hit
me: the View->Web Browser is there ! It's there in 5.5 too.

Now, why would my standalone application need it ? It's not like
people use some other "internal" broser that each application has, so
why is it there? Or at least -- why the menu item ?

There was a comment in a blog at some point with something like "we
like Eclipse RPC because there we have to put things in, on the
NetBeans Platform we have to take things out first" which kinda made
sense (although I haven't used the Eclipse RCP, only the IDE).

I've dugg into the sources and it seems the Web Browser is used by the
*autoupdate* module. But even if I don't use the autoupdate module,
it's still there. Ok you'll say: "there is a trick! You never actually
remove autoupdate entirely", which is true. Autoupdate also has the
little update piece generated from libsrc/ that has low-level module
update/install code.

But the Web Browser usage in autoupdate isn't in the *libsrc/* part,
it's in the module, that you can disable.

Also, in Tools->Options->Advanced Options->System there is a Web
Browser option (with Swing Browser as the default). And that is needed
... why ?

Of course, one can always set a _hidden in tha layer for the folder or file and thus hide the Web Browser menu item or the whole View menu but this seems indeed a little odd. In the end -- what is the purpouse of the Web Browser that makes it so hard to remove altogether ?

If this was helpful for you then maybe you'll like reading the other NetBeans Platform-related posts.

--
Emilian Bold
Java-loving consulting services from Timisoara, Romania.

Friday, August 18, 2006

NetBeans Platform: Options Dialog and SPI

A nice thing in NetBeans Platform and IDE 5.0 is the nice Options dialog from the Tools menu. I've developed platform modules on NetBeans Platform 3.6 and skipped the whole 4 release so I'm not sure if it was introduced in release 4 or 5.

Anyhow, it's a nicer way to present options to the user than the usual tree display (now in Advanced Options). Also note that the Properties Window is also getting somehow deprecated and not recommended (unless in 3.6 where everyone was drooling to use it).

The NetBeans IDE Wizard for a new Options Panel is great. It generates the Bundle, the OptionsCategory , the OptionsPanelController , the swing JPanel, copies the icon and modifies your layer.xml .

An Option panel may reside in it's own "tab" or in the Misc area. This means that your class (subclassing AdvancedOption or OptionsCategory ) is registerd in the layer in


<folder name='OptionsDialog'>
<!-- here for OptionsCategory file/class -->
<folder name='Advanced'>
<!-- here for the AdvancedOption file/class-->
</folder>
</folder>


Basically the AdvancedOption and the OptionsCategory represent the name and icon of your Option panel and also the factory for your Controller.

The controller takes care of stuff such as saving your options and loading them, offer listeners and provide data outside such as "does this panel need to be saved ?" Easy short methods that are generated for free by the Wizard.

The controller is the one that provides the Swing JComponent for your panel. Of course that people usually have a JPanel (as the wizard generates).

Now, a nice thing about this API is that it even takes into account the situation when the settings are invalid. For example the user changed the Country but forgot to update the phone number or something. Because usually it's easy to provide a GUI warning (like a little red icon) but the API must also help.

Basically only the load() and store() methods from the JPanel must be filled after you generate the GUI interface with the form editor. I think the SystemOption -s are going to be deprecated or rewritten soon so I use the standard java Preferences.

Of course, if your panel may also be in an invalid state, the valid() method must also be implemented. Take a look at a simple valid/invalid Panel:




Hiding the Misc Options tab

And if you have a standalone application and you want to have only our option in the dialog (withou the Misc option), it's easy. Just edit the layer.xml and

<folder name="OptionsDialog">
<file name="Advanced.instance_hidden"/>
</folder>


If this was helpful for you then maybe you'll like reading the other NetBeans Platform-related posts.

--
Emilian Bold
Java-loving consulting services from Timisoara, Romania.

Thursday, August 17, 2006

NetBeans Platform: DataLoader, DataObject and DataNode

The Loaders API is one of those things in the NetBeans Platform you know it exists, kinda know what it does but never dare to use it since it seems either too complex or not necessary.
For my current project I said I'm going to use everything the Platform has to offer and try not to re-invent anything so I had to use the dreaded Loaders.

The ideea behind the Loaders is quite simple: the IDE/Platform has to work with lots of file types (as in extension or MIME) and each DataLoader must take care of recognising it's file or files and represent it with a DataObject .

I say file or files because there is no one-on-one (1:1) relationship. The simplest example is the form editor that generates a single DataObject from the .java and .form files.

The wizard NetBeans 5.5 offers is more than enough to get anyone stared with the Loaders. Just ask for a File Type wizard, choose the file extension or MIME and quite fast you get everything autogenerated.

Basically each DataLoader is registered in the DataLoaderPool so each new file (as in FileObject) is queried against all the DataLoader-s to see if it is recognized or not. There also seems to be a mechanism to avoid creating a DataObject more than once - probably since it's considered expensive to parse / load the file.

Now, DataObject-s seem to be a lot more complex than meets the eye and I hope to post another message about these. There are ways to add listeners, cookies, move/delete methods, etc. Surely these methods are put to good use inside the IDE but I still haven't found a way to match and use there features yet.

The last thing related to the Loaders API is the DataNode . This is just a Node representation of the DataObject. The "view" part that I imagine as the GUI parse-tree.

What I fail to understand about the Loaders is the fact that some global actions like SaveAll seem to need a DataNode in the activatedNodes of a TopComponent which means that, although you could live and develop Platform applications without using DataLoader-s at all, it kind of forces you if you need SaveAll. This also means for me that basically you can't get a SaveAll action without first saving something to a FileObject. I was under the impression that SaveAll means "save all unsaved documents" not "save all unsaved documents already with an attached path".

If you've spotted any mistakes are you are able to clear some things in my Loaders mist, feel free to leave a message or contact me.

If this was helpful for you then maybe you'll like reading the other NetBeans Platform-related posts.

--
Emilian Bold
Java-loving consulting services from Timisoara, Romania.

Wednesday, August 16, 2006

MindMapping with the NetBeans Platform

I've started work on a free mind-mapping module for the NetBeans Platform (with graph.netbeans.org). Not planning anything fancy, just a well done NetBeans Platform-based application with help, autoupdate, etc.
I expect the feature list to be close to the features of FreeMind or other open-source tools.
What I do want is import from these other free formats in order to have a simple migration guide for the existing users.
I also planned some tutorials / podcasts as I come along but I think I'm overly optimist so I'll be happy if I just manage to finish the first version untill me self-declared deadline of 4th September 2006.

Monday, July 10, 2006

Units API (javax.units) live again !

It was a real shame that javax.units (aka JSR-108) died because of lack of interest. Some nice libraries already use it (geotools for example) and the Java world doesn't have a standard way of talking about units.

Unit measuring seems a very handy way to prototype some nasty formulas. Remember the old: forgot it was metric unit error ?

Well, now javax.units is reborn under JSR-275, with a RI based on JScience. There also seems to be a new package now: javax.quantities. I'm going to read the spec to see what's this about.

Pearls before AIs

There's an interesting phenomenon I've noticed and I'm not sure I have a good word for it. One has various ideas jumping around ...