refactor to share the logic to determine which java to use