A working Java version