File () { final File brewDir = new File("/usr/local/Cellar/maven"); final String[] list = brewDir.list(); if (list == null || list.length == 0) { return null; } if (list.length > 1) { Arrays.sort(list, (o1, o2) -> compareVersionNumbers(o2, o1)); } final File file = new File(brewDir, list[0] + "/libexec"); return isValidMavenHome(file) ? file : null; }