finished java version