Thursday, December 20, 2007

The opensource bureaucracy

I always thought that only post-communist countries like mine can be bureaucratic and not capitalist, civilized countries or the meritocratic internet.

But one may be shocked to notice the kind of bureaucracy open source brings. In a normal "distributed" project where you don't have a sugar-daddy to pay for all the project hosting and other expenses, you need to get some free hosting.

This is the first place where you need to get an approval for your hosting, depending on what you do (you can't expect to have any project approved) or what license you use (you get the free hosting if you give your work under their preferred terms).

And the more "free" stuff you need (like build servers, wikis, email lists) the more you have to wait, accept rules and abide by them. But generally, wait and read a lot of strange disclaimers and terms and conditions.

Don't get me started when you get to the licensing part. Do you want your code into some high-profile codebase ? You need to sign the agreement, which needs to be scanned and emailed or even better faxed. Then you need to wait for the acknowledgment that the fax did arrive and someone is going to give you commit access, in a few days.

Basically the more people you involve the more it takes to do anything, especially since you depend on their goodwill. The more "steps" you have to follow, the more agreements you have to approve of, the more time you have to wait.

I'm waiting for a month now for some approval on a high-rated open-source nexus. I'm not being denied, I'm just waiting for someone to finally get to my item in the todo list.

It almost makes renting my own server seem like a good expense.

Thursday, November 15, 2007

I really like Java's tooling

There, I've said it.

Really, Java has great developer tools.

Long ago I liked to experiment with a lot of different programming languages (I own lisp.ro). Many languages got things right from the beginning while Java with the C++ inheritance is really, really verbose. Nowadays I mostly play with Python, Javascript (and studying Erlang).

But what Java lacks in succinctness compensates in tools. Big, juicy, gooey tools.

First, a bow to the JVM. It's such a nice feeling to develop on OSX and only test rarely on Windows and have everything work !

Second, I really like my NetBeans IDE with my debugger and trusty profiler. Problem with the EJB: bam! add --debug to Glassfish and connect from the IDE. Possible performance problems? kpow! attach the profiler to the application and see what's the problem.

Wanna see the health of your code: put a whole bunch of reports in maven and build your site (findbugs, pmd, taglist, checkstyle, all good stuff).

And if you feel in a coding mood, why don't you add a MBean to get quick info from jconsole, even remotely? Or even better, make a custom JMX client using JFreeChart to get a nice display of the health of the application.

It just feels like software engineering. And it's nice.

Tuesday, October 30, 2007

Java 6 meet Linux on MacBook Pro

It seems there's no Java 6 in the new OSX Leopard from Apple.

I mean, it's not like it's been almost 11 months since SUN released Java 6 on Linux, Solaris and Windows. And I bet it's more than an year since Apple started getting code for Java 6 from SUN in order to customize it in due time.

But I guess the iPhone and transparent menu is far too important to actually put some developers work on Java.

It's bad enough that they are supposed to force down on my throat a new OS release for a new JDK version -- I just want Java 6 on Tiger thank you very much. But now, they are delaying even that !

So, I'm thinking that in the future I'll probably go back to Linux and stay there. I thought proprietary Microsoft software is bad; well, I'm starting to believe maybe proprietary Apple software is just as bad (only prettier).

Hence, the first step is to get Linux working and see the hardware support. Because if it's not good enough I might just go for a Thinkpad.

What about that Apple ?

Monday, October 22, 2007

Coupon or negative numbers' marketing

I've noticed a little trend in TV commercials nowadays in Romania and it also applies to computing: new commercials or new advertisements always underline the negative number, the "user gain". Stay with me...

So, you want a new car ? Well, our car is the best: it's 1000 euro "buyer (bar)gain".

Want to be subscribed to our useless service ? How could you refuse: the first month is free!

Why don't you migrate to the new version: it's 10% faster !

Want to take a 20 year long mortgage for 100K euro ? We are the best: we give you 4K euro for free.

As you noticed, all these advertisements avoid the real issue. They avoid, the actual price (or actual speed, actual time to completion, etc).

All they brag about is that you get this discount or that super-offer. But they don't even bother to tell you the actual cost anymore.

I mean, in their mind, getting anything for free should be reason enough for people to buy their product. Makes sense to me... NOT.

My opinion is that this coupon advertisement is trying very hard to confuse the buyer. Because if anyone uses the same unit for their product like price, it's easy to compare products.

But how hard is it to compare an offer where I get 2 free months with one that gives me a free (cheap) cell-phone or another one where I may have already won an all-expense paid trip to the Bahamas. See ? It's almost impossible.

So, please, marketing gurus, stop telling me things I don't care. Tell me things I can quantify: if I get a discount, how much will it still cost ?; if your product is faster than the old one, how fast is it actually (maybe the old product ran on Cyrix processors).

The exception is when I already am a customer so I do care what I have to gain. 10% speed: sure ! Half memory usage: excellent ! Less CPU usage: even better.

Thursday, October 18, 2007

New NetBeans Platform-based tool

I just noticed on my RSS feeds some talk about VisualVM so I went and downloaded it.

First, by the screenshots alone it was clear to me it's a NetBeans Platform application. Also, the charts look awfully like the NetBeans Profiler ones. Well, lo an behold, it is a simple Platform application holding the profiler cluster.

What's annoying me is that the profiling part only works with Java 6 (not available on OSX). But the NetBeans Profiler does work with Java 5 if we just configure the proper agent. I would have been nice for VisualVM to also use the agent as not everyone is using Java 6.

Second, the OSX integration is less than stellar (it's the 1st release so I'll excuse them). The menu doesn't show up on the apple menubar the 1st time you run the tool (but on subsequent runs it does, strangely). Also, no launcher like in the IDE.

Oh, forgot to mention it uses the NetBeans Platform from NetBeans 6. Looking good guys.

Thursday, October 04, 2007

(Maven) Building to a ramdrive

I own a MacBook Pro and I have a few projects with Maven (and MevenIDE on NetBeans).

What's annoying me with the build system is that it usually writes a lot to the disk. Not only is that quite unnecessary (as the files will be overridden in no time) but the laptop hard-disk is also quite slow and all this writing is trashing it.

The solution: write to a ramdrive ! As you all know, a ramdrive is a "virtual" hard-disk that sits in your RAM and goes away when you shutdown the machine (not that I care, the build files are temporary).

First step: create the ramdisk

There are some utilities that do this, but it's quite doable from the terminal (eventually with a shellscript).

  1. First, get your disksize in MB and multiply it by 2048. So 256MB means 524288.
  2. Next, create the device: hdik -nomount ram://524288 The command will also display the name of the new device file.
  3. Create a HFS filesystem in there: newfs_hfs -v "disk name"/dev/diskXXX , where diskXXX is whatever the previous command printed
  4. Mount the filesystem: mkdir /Volumes/diskXXX &&
    diskutil mount /dev/diskXXX
You'll probably need to run some of these commands as root (su admin-user, sudo sh). I also set my non-admin user as owner with chown -R myUser:myUser /Volumes/diskXXX

At this point you should have a new 256MB drive mounted.

Second step: link maven folders


Now, I have to set the "target" folders on the ramdisk. Normally the orthodox way is to change the pom but I just didn't get it working. So my old-school solution is to use symbolic links.

This could be smarter as a "mvn clean" will remove the links we just create (but just keep a script in place that recreates this).

My script is:

for i in *; do
echo $i;
mkdir -p "$1/$i/target";
ln -s "$1/$i/target" "$i/target";
done

and I run it in the folder that keeps all my Maven projects (a flat hierarchy). Note the $1 which is the argument to the script. I use it like this:

$./linkramdisk.sh /Volumes/diskXXX

Building

All the links are in place so you can try a mvn install and see how fast it works. I my case, I reduced the build time (with no unit-tests) from 27 seconds to 17 seconds.

That doesn't seem much, but it does add up for larger projects and most importantly, it keeps the hard-drive out of the loop.

Oh, did I mention I also use FileVault on my account ? That's another reason one would like to avoid writing to disk: no need to encrypt something useless like a build artifact...

Saturday, September 08, 2007

Power-efficient CPU a non-issue ?

I find it interesting nowadays that CPU builders, and Intel in particular keep bragging about their power-efficient CPUs. It's like, this is getting more important than speed or number of cores.

My point is: who cares about that ? I want my CPU to be fast first, eventually have multiple cores and some fast way to talk with my memory. It would be nice to also consume little power, but that's a nice touch so to speak.

I assume 90% of the CPU buyers don't have server farms to worry about their electrical bill so why induce this trend ?

I think the solutions is clear: Intel / AMD cannot increase speed easily anymore. Therefore they are convincing consumers that this is what's important about a CPU: power consumption. The result: you see all kinds of uninformed users wondering how much the CPU consumes as if they would see the difference.

I don't want my CPU to consume less than my graphics card or my hard-drive. I'm buying it to work so I expect it to take some power. I would gladly take the power-hungry fast CPU than the low-consuming slow CPU.

As far as I know the operating system or any other software in this world isn't influenced by how much power the CPU takes, but it sure matters if the CPU is faster or has more cores (or some multi-threading per CPU).

So, congratulations to the marketing departments of Intel for convincing people that it's not speed or threads that matter (you know, the stuff people need) but power consumption.

Probably the PC already consumes less than my fridge, old TV or hair drier, but God-forbid it consumes more and gains some speed. No way, we have to be power efficient :-)

Tuesday, September 04, 2007

I saw Vista for the first time yesterday

Yesterday a neighbour of mine bought a new computer. It was a decent-ish desktop (3.0Ghz with HT, 1G Ram, 300G HDD, 19" LCD, 5.1 speaker system) but way overpriced. Could have bought an iMac probably with those money.

Anyhow, since I'm the computer guy in the building, they came to me to get it started. First, because they had no sound. Also, because they have a speaker system with 5 or so satellites and only a 2 way sound card.

And this is how I saw Windows Vista for the 1st time. I was really weird as I haven't used any Windows in a while but Vista made me even more uneasy as I just couldn't find the settings I was used to in the XP-using days.

So, fast-forward 1 hours or so after I've installed the sound drivers. The strange thing was that the system was rather slow and unresponsive, especially while installing stuff. I mean, this is better than any machine I own so I expected it to fly. But no, it was just about as slow as my iBook G4.

About those accept/deny dialogs I've read about on the internet, I have to say I only noticed them a few times. I guess if you let Vista be, it doesn't bother you with messages :-)

But the thing this experience showed me is just how foreign Windows looked to me. Mostly due to Vista but the point was that Windows in general is something I don't know much about anymore.

I've used so much other operating systems that I've become more or less a Windows beginner.

I think that generally there isn't a need for Microsoft anymore. Windows is redundant with OSX / Ubuntu, MS Office easily replaced by OpenOffice, Explorer by Firefox.

They don't actually seem to have any product anymore I would need. And this is a nice feeling.

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.

The case of the different jsch 0.1.54 binaries

As part of the Apache NetBeans IP clearance we are combing through all the code and dependencies. One interesting thing we bumped into wa...