Improve defaultJava() function