Weak References in Java

Ever heard of Weak References in Java? Well, me neither. But it really sounds useful and you should give it a try.

,

No Comments

FOP: Embedding fonts from classpath

If you’re using Apache FOP to create PDF/A you’re forced to embed all fonts (even the base 14 fonts).  Generally there are two options how to embed the fonts:

  1. Let FOP auto-detect the fonts
  2. Create a font metrics file and tell FOP where to find it

Read the rest of this entry »

, ,

3 Comments

String concatenation

One of the first things developers learn about String concatenation in Java is that the “+” operation does the magic. In this case the magician is the compiler. Lets look how the following code snippet gets translated by the compiler.

// Sample.java
String buffer = "";
for (String string : listOfStrings)
{
  buffer += string;
}
// Sample.class
String buffer = "";
for (String string : listOfString)
{
  buffer = new StringBuilder(buffer).append(string).toString();
}

Every time the String concatenation is invoked a new StringBuilder instance is created and but never assigned. Hence it is immediately eligible for Garbace Collection. What a waste of Memory. If you really need to concat Strings in a loop you better do it directly with a StringBuilder.

,

1 Comment

RIP Sun

No Comments

One cold day in hell

Chemistry class at Maynooth University in Kildare, Ireland.

The answer a professor got from one of his students was so “deep” he had to pass it to his colleages via internet:

Bonus-question:

“Is hell “exotherm” (gives off heat), or “endotherm”(absorbs heat)?

Read the rest of this entry »

2 Comments

Google Collections Library 1.0 available

Last year on Dec, 30th Google released version 1.0 of it’s Collections framework. Although Apache Commons Collections provide a rich set of enhancements to the standard Collections framework Google’s implementation has two big advantages:

  • Based on Java 1.5 and hence using Generics
  • More standard compliant (Commons Collections occasionally break standard behavior)

Go to their website and make sure to read the FAQ.

,

1 Comment

Save MySQL! campaign

Michael “Monty” Widenius, the man who brough us joy and pain by creating MySQL, has started a campaign for saving MySQL. He demands that that the European Commission should only approve the Oracle/Sun deal if

  • MySQL will be sold to a competitor or
  • Oralce guarantees (by signing some paper) that all previous version of MySQL will still be freely available and additionly will be released as free years for the next three years.

I’m not giving anyone an advice whether to sign the petition or not but everyone should take a look at the campaign and decide on which side he or she stands. More information about the topic and a little Q &A can be found at Monty’s blog.

,

No Comments

Closures in Java

One of the most discussed (and most controversial) topics in the last years concerning the future of Java was the introduction of Closures. After 2008′s Devoxx Closures were off the Java7 release. One year later at the same event Mark Reinhold revoked it and announced that Closures will be in Java7 (and hence delaying Java 7 for a few months). Read the rest of this entry »

,

No Comments

JavaEE 6 has been approved

On Monday the final votes for “JSR 316: Java Platform, Enterprise Edition 6 (Java EE 6) Specification” have been submitted and with little surprise it has been approved.

JavaEE6 marks a major milestone in enterprise Java with the arrival of subspecs such as CDI, JPA2, EJB 3.1 (with EJB Lite) or Servlet 3.0. But the most important part for me is the new web profile which was really overdue. Read the rest of this entry »

,

No Comments

It’s /WEB-INF/classes/META-INF

Note to myself (which might help others):

In a web application always put the stuff (which is not packaged a single JARs)  in /WEB-INF/classes/META-INF (e.g. persistence.xml or service files) and not in /META-INF. Otherwise the various applications will not be able to locate them.

No Comments