Monday, March 7, 2011

Currency

I'm in Europe, sometime I need to write prices in euro, in emails, documents etc. However I use an American keyboard, on a mac, which makes things a bit trickier when one wants to use the € symbol…

But I found a shortcut that works, I just have to remember it now:

⌥ + ⇧ shift + 2

Thursday, July 22, 2010

Injecting enums with the Spring Framework

Today I needed to inject an Enum into a bean's constructor using Spring.

First I thought I'd need to write my own FactoryBean or 'better' a PropertyEditor.

Well no need, it is already nicely handled by the framework. After a bit of googling, I found the documentation in Appendix A of Spring's reference

And here is what actually works just fine. If I have the following enum:

public enum Language {
 EN, FR
}

And the following class that I need to instantiate with Spring:

public class LocalisedLogger {
 private final Language lang;
 public LocalisedLogger(Language lang) {
   this.lang = lang;
 }
}

Then I can just configure it like this:

<beans>
 <bean id="logger" class="org.leberrigaud.example.LocalisedLogger">
   <constructor-arg value="FR">
 </constructor-arg>
</bean>
</beans>

That'it! Spring does the rest…

Wednesday, July 21, 2010

Java versions on Snow Leopard

It seems I have a few issues with java and versionning theses days. This time I got bitten by Java's version on Snow Leopard. Indeed whatever version you think you're using it is Java 1.6!

What got me is the JDBC api and namely the new java.sql.Wrapper interface added in 1.6. Thank god for build boxes (running Linux ;-))

I now remember that I had to install manually Java 1.5 on my work machine, when I was in Sydney. I am now working on my laptop and forgot to do that. I couldn't remember the exact procedure but someone wrote it for me. Thanks to Ted Wise!

Tuesday, July 20, 2010

Java major.minor version

You're bound to see those errors at some point if you're a java developer, something that says Unsupported major.minor version 49.0, or similar.

I always forget which number corresponds to which version of Java, so there it is:

JDK 1.4
48.0
JDK 1.5
49.0
JDK 1.6
50.0