working jdk6 solution