File () { final File symlinkDir = new File("/usr/share/maven"); if (isValidMavenHome(symlinkDir)) { return symlinkDir; } // well, try to search final File dir = new File("/usr/share/java"); final String[] list = dir.list(); if (list == null || list.length == 0) { return null; } String home = null; final String prefix = "maven-"; final int versionIndex = prefix.length(); for (String path : list) { if (path.startsWith(prefix) && (home == null || compareVersionNumbers(path.substring(versionIndex), home.substring(versionIndex)) > 0)) { home = path; } } if (home != null) { File file = new File(dir, home); if (isValidMavenHome(file)) { return file; } } return null; }