Platinum Solutions Corporate Website


Java

Handling MS Office Curly Quotes (and other Unicode/UTF-8) in Spring MVC.

A nagging problem that has cropped up on the last 2 projects I've worked on is users cutting and pasting from MS Word into a text area, including curly quotes (“smart quotes”). These always end up as junk after the request is submitted back to the server. For example, the left curly quote ends up as “ (The characters with the codes 226, 128, and 156 respectively).

JavaRebel

Recently, I was listening to the The Java Posse, part of which is a segment called Java Application of The Week (or somesuch). One of the recent apps was a product called JavaRebel. According to their website, the product "enables you to see changes to your code immediately, without the need to redeploy an application or perform a container restart".

Java as Windows Service with Apache Commons Daemon

Recently, I wanted to take a Java command line program and turn it into a Windows Service. There are a number of ways to do this, but I decided to try out the Apache Commons Daemon project (http://commons.apache.org/daemon/).

It is actually very simple to turn your Java Program into a service with Commons Daemon but, if you’re like me, you will very quickly become confused by browsing the project page, so here are some tips.

Procrun

Inconsistent escaping in Spring MVC resource bundles

While our team was working on a Spring MVC application, we found that sometimes a message retrieved from a resource bundle had to have apostrophes escaped (by doubling them) and other times we didn't. I did some research to find out what was happening.

It turns out that Spring requires escaping or not depending upon how the resource is referenced.

Reading the Windows Registry w/ Java

Recently, I had to do something I never had to do before: read the Windows registry from Java. I would have thought this would have come up at some point in my career, but there's a first time for everything.

I ended up using an open source project based on JNI called jRegistryKey - http://sourceforge.net/projects/jregistrykey/. It's super simple to use, you have to drop a DLL somewhere on the Windows path, put a jar on your classpath and then simply use the API and it works like a charm.

Attached a little code snippet that demonstrates the use.

Rumors and mysteries

A company called GemStone Systems, who's focus is enterprise and performance, has a teaser site that's got a few people talking...

Ruby that scales™

http://ruby.gemstone.com/

What are they up to over there? Not sure yet, guess we'll have to wait for RubyConf '08... but it could be interesting.

PDF generation w/ Apache FOP

My current project requires the generation of PDF reports in a web-based J2EE app, using free tools. Everyone knows about Jasper and iText, but our requirements are for a small number of somewhat simple reports, so I thought those would be overkill. Not to mention the fact that my preference is to use presentation technology that is familiar without any custom coding.

Easy toString() Creation

Overriding the toString() method is an all too common Java developer experience. It’s also somewhat tedious: Write out the class name… write out some properties and their values… format it so it doesn’t look hideous… repeat for lots of other classes.

Wouldn't it be better if there were an automatic way to generate decent looking toString() methods?

Apache to the rescue!

New Features in Groovy 1.5

Just over a month ago the Groovy team released the latest version of Groovy, a dynamic programming language built specifically for the JVM (Java Virtual Machine). This version offers a variety of functionality and performance improvements over previous Groovy releases.

Note: The latest version of Groovy is actually 1.5.1 - a bug fix release. All code examples in this post were run using version 1.5.1. Click here to download the source code examples and follow along.

Commons Collections and Generics

I've made extensive use of Apache Commons Collections over the years. It has a lot of really handy wrappers and utilities for doing list and set manipulation that Java doesn't do out of the box. So, in my current project I am using jdk1.6, generics, and all that good stuff. I was using the LazyList class and got the old List is a raw type. References to generic type List should be parameterized warning from Eclipse. So, I thought to myself: "Oh bother.. I bet it doesn't support generics yet." I did some poking around, and confirmed that.