Beware of unlocalised JREs

This is a cautionary tale of US-only JREs and non-US countries, such as The Lucky Country I call home.

Sun, in their infinite wisdom, provided (until recently) the Java Runtime Environment in two different flavours: US English only, or all languages. Unfortunately, when you place the “US English only” version on a non-US machine, you get some weird errors, like this one (for Australian machines):

// Throws java.text.ParseException, believe it or not.

This one is a bugger to reproduce on a developer box, because the developer box will almost certainly have a Java SDK on it instead. However the SDK only comes in the “all languages” variant, which means this code will work as expected.

Furthermore, because the “US English” and international versions are identical, except for the language pack, you can’t tell them apart using ‘java -version’. The only way to tell is to look in the ‘lib/ext’ directory of the JRE. The international version has a ‘localedata.jar’, while the “US English” version does not. Not surprisingly, the localedata.jar has all the resource bundles for different locales.

(For those who want more details… the formatter fails because it thinks that the currency symbol should be ‘AUD’, not ‘$’)

This particular problem had one of the development teams at work tearing their hair out for about 3 days; we’d stared at the code where the ParseException was caught and said “No, that couldn’t be it”, but enhanced the logging anyway (future reference, fellows: You should always log “impossible” exceptions, at least). Even after we proved it was the ParseException, it took a while to pin down the cause.

Sun, again in their infinite wisdom, now only distribute a fully international version. If you want to see this for yourself, compare the downloads of the JRE for a Java 1.4.2 release to the older Java 1.4.1 release.

(This blog entry done on behalf of the team at work; I know you guys will be looking out for it. 😉

Author: Robert Watkins

My name is Robert Watkins. I am a software developer and have been for over 20 years now. I currently work for people, but my opinions here are in no way endorsed by them (which is cool; their opinions aren’t endorsed by me either). My main professional interests are in Java development, using Agile methods, with a historical focus on building web based applications. I’m also a Mac-fan and love my iPhone, which I’m currently learning how to code for. I live and work in Brisbane, Australia, but I grew up in the Northern Territory, and still find Brisbane too cold (after 22 years here). I’m married, with two children and one cat. My politics are socialist in tendency, my religious affiliation is atheist (aka “none of the above”), my attitude is condescending and my moral standing is lying down.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: