Posts

Showing posts from 2008

Java Enum relational modelling

As I have blogged about before, the Java Enum is almost perfect . I say almost because of the annoying restriction that its constructor cannot include a relation to itself, due to forward reference limitations when using the Sun compiler. The issue came up again recently when I wanted to model authority roles in Wicket , so I spent a bit more time with the issue and the following is what I've learned. First though, a recap of the original problem. Consider the following attempt at modeling states of a CD player: public class IlligalForwardReference {     enum Player{         PLAYING(Player.PAUSED, Player.STOPPED),         PAUSED(Player.PLAYING, Player.STOPPED),         STOPPED(Player.PLAYING);         private   final EnumSet<Player> transitionStates;         Player( final Play...

Jasper Reports and legacy formats

I'm not sure when exactly or between which versions, but at some point Jasper Report designs moved from being based on legacy DTD to the more modern XSD schema. It turns out that most tools today, i.e. the iReport plugin for NetBeans, are now overwriting the DTD information of legacy designs in favor of XSD information. This can cause problems if and when you are not able to change the Jasper engine itself that fills out the template designs. It also did not seem possible to simply plug-in another XML parser and I found it rather hard in general to find information about this and support forums to turn to. So I sought another solution. If you try to run an XSD based design against the Jasper engine that can only deal with DTD, you will get an error along the line of this: net.sf.jasperreports.engine.JRException: org.xml.sax.SAXParseException: Document root element "jasperReport", must match DOCTYPE root "null". By using a legacy designer which favors DTD's (...

Congratulations America!

Image
I think it's only in order to congratulate the USA for what has happened. While oddly 47% of Americans still haven't noticed, the last 8 years of an illiterate republican doctrine "if you're not with us, you're against us" has hurt their country incredibly much. As evident right from the beginning to most of us, Bush will go over in history as the worst president of all time - only elected for his second term I suppose due to that fuzzy term called "American patriotism". The only sad part will be missing someone to laugh at when watching Letterman, The Colbert Report or The Daily Show. Ah for a while at least, we'll always have Gucci Palin. ;) Best of luck Obama, you sure have your work cut out for you! The future just got a lot brighter in the prospect of regaining an America so many of us used to admire once! With a new dawn near and a fresh breeze blowing from the west, let the healing begin.

Groupwise 7 on Ubuntu 8.04

While web applications in browsers are continuing to improve, they still can't quite compete with desktop applications. One of the examples of this is the Novell Groupwise client. Running 64bit Ubuntu poses a bit of a challenge, since Novell only offer prepackaged rpm bundles for 32bit Red Hat and Suse systems. Note, some of this stuff is inspired by Scott's blog entry earlier this year, however I could never get his howto to work for me. Start by downloading the Groupwise client RPM onto a 32bit version of Ubuntu (I use a 32bit image in VirtualBox). I'm not sure from where I found mine, but it's out there if you search a little. You should end up having a file called something like novell-groupwise-gwclient-7.0.3-20080310.i386.rpm To convert this into a debian package, you are going to need alien. Get this by typing: sudo apt-get install alien With alien, you can convert the RPM into DEB by typing: sudo alien -c novell-groupwise-gwclient-7.0.3-20080310.i386.rpm Now yo...

Java 6 update 10 on Ubuntu 8.04

Image
The official Ubuntu 8.04 repositories comes with a slightly outdated version of Java, namely 1.6.0 update 6. If you issue a java -version you can assert this is the case: Unfortunately, if you are running Compiz, you are likely to then suffer the notorious gray rectangle syndrome as described in 6429775 , 6434227 and 6632124 among others. The good news, the problem appears to be fixed in update 10. Installing the latest JDK Start by downloading the JDK for your architecture from SUN. Take the .bin file, extract it by running it as a shell script: sh jdk-6u10-rc2-bin-b32-linux-amd64-12_sep_2008.bin This will create a new folder called /jdk1.6.0_10. Rename this to java-6-sun-1.6.0.10 (just to remain consistent with how Debian/Ubuntu refers to JDK's) and move this folder to /usr/lib/jvm: sudo mv jdk1.6.0_10 java-6-sun-1.6.0.10 sudo mv jdk1.6.0_10/ /usr/lib/jvm Officially you are suppose to use the update-java-alternatives command when using a Debian distro, but frankly I find it ea...

@SuppressWarnings completion

Image
Why it was made Although NetBeans is capable of suggesting and auto-inserting @SuppressWarnings, it doesn't actually provide code completion or documentation for these values. Indeed, as I've blogged about before , it is tricky to track down the exact enumeration and semantics of these magic values. This is due to the fact that they are entirely dependent on the compiler and IDE. This plugin adds support for the values currently supported by NetBeans 6.1, namely "cast", "deprecation", "divzero", "empty-statement", "empty", "fallthrough", "finally", "serial" and "unchecked". It also tries to explain how and when to use them. How it was made Creating plugins for NetBeans is relatively easy if you start by grabbing existing code and have invested in the RCP book. Especially blogs like Geertjan' s and Sandip's are virtual goldmines. So for this one, I used the Geertjan's blog entr...

Myth: Java widely used in the browser

This summary is not available. Please click here to view the post.

NetBeans on speed

Image
In the post from yesterday I was a little harsh regarding the performance of recent NetBeans versions, which seems to have taken a toll for the worse. One of the most annoying things is how much scanning and processing is going on all the time which harms responsiveness and the overall user experience. The NetBeans mailing list yielded responses like "more features requires more work" which is fair enough. However, I decided I wanted to have my cake (speed) and eat it too (features). Memory mapping to the rescue It's not exactly new. So called "RAM drives" have been used for ages to speed things up, some Linux distro's even mount the temporary files location into RAM to improve performance. We can do the same to our source checkouts to gain massive increase in throughput as well as access time. There are two easy ways to archive this out of the (Linux) box, mount a dedicated RAM drive or use the TMPFS filesystem . Sorry, Windows users will have to look els...

NetBeans: Pretty Much Unusable

NetBeans Pretty Much Unusable If you care about NetBeans and its performance, an interesting development occurred over the last 24h on the nbusers mailinglist. It seems the upcoming 6.5 release sparked a debate claiming that it's pretty much unusable . While I wouldn't go that far, there is actually some truth to the matter as experienced by my colleagues and I. A little bit of history I've been back and forth between various IDE's over the years, coming from Visual Studio (VB/C/C#) I've been rather spoiled in regard to syntax highlighting, code completion and debugging. In fact I remember back in 2001 how I was convinced into doing a college project in Java, primarily because of the assistance offered by Visual Studio J++. At that time, no tool provided these kind of features (although Forte and JBuilder tried). In this day and age, things looks quite different of course. SUN finally realized that it's worth having great tools (some would argue they have to sol...

JSF and binary content

So I have been learning JSF and JPA at work recently. While I can't say those are the most exciting technologies to me, at least they appear to be (or become) de-facto standards and that means more leverage over the long term (something not always the case when dealing with Java technologies). Using JSF with Facelets can be a little challenging, the tools are only so-so and frankly it bugs me to have to type so much type-unsafe stuff in XML, EL and annotations. Anyway, what this blog entry is about is how you can bridge the gab between JSF page rendering and binary content delivery. JSF and PDF Corporate applications often need to deliver a lot of PDF content, and it is no different where I work. Static PDF documents as well as dynamic ones. Even if frames and iframes are generally frowned upon these days, I find then to be the best way to embed PDF documents inside the browser. However, with JSF you can't just make an xhtml page and expect to be able to stream binary content f...

The Enum is perfect... well almost.

Ok so its time to admit to something. I'm deeply in love with Java's Enum! In my opinion it was the best part of Java 5 and I still wonder why it took Sun 10 years to add this powerful static modeling construct. The power of the Enum Although there certainly are known limitations of the Enum, i.e. how you can't extend it , I have never run into a practical limitation myself. Until now that is. The issue I want to raise is that of Enum forward referencing . The great Alan Turing taught us that at the end of the day, everything can be modeled by a Turing Machine and finite automata. We may not often consciously operate at this level, but many things still makes sense to model this way being it a regular expression matcher, navigation rules or similar. The Java Enum appears to be a perfectly simple, fast and type-safe way of modeling this... or does it? State machine with an Enum Since the Java Enum effectively is just a group of static class instances, it allows us to attach...

NetBeans plugin: Special copy/paste

Image
The very little I've had to paste code into this fairly new blog, was enough to give me the idea of creating an extension to NetBeans which would help to remedy this formatting nightmare. Now, in my world, there's approximately a 100:1 ratio between idea and actual realization, so I'd have to salute the awesome OpenIDE API's for making this possible spending just a few late nights and taking just 200 lines of code. Without further ado, I present, my first NetBeans plugin . Special copy/paste The plugin will add a couple of new actions to the context-sensitive popup-menu of the source editor, which will allow you to copy the selected text as preformatted HTML, as well as a CSS version which will preserve the formatting used in NetBeans. Using the "Copy as HTML and CSS" menu as in the above screen dump will result in you being able to paste it directly into a website/wiki/blog and have it display like this: /** * @param args the command line arguments ...