public List<String> locateJDK() {
        String JAVA_WINDOWS = "where javac";
        String JAVA_LINUX = "readlink -f $(whereis javac)"; // readlink -f $(which java)
        //String JAVA_MAC = "ls -l `which javac`";
        String JAVA_MAC = "/usr/libexec/java_home -v 1.8";
        String osName = System.getProperty("os.name").toLowerCase();
        //osName = "mac"; // for simulating a mac machine
        List<String> candidates = new ArrayList<>();
        if (osName.contains("win")) {
            //C:\Program Files\Java\jdk1.8.0\bin\javac.exe            
            String commandResult = executeCommand(JAVA_WINDOWS);
            Pattern pattern = Pattern.compile("\\s*((?<path>.:\\\\.*?\\\\javac.exe)(\\s|$))", Pattern.CASE_INSENSITIVE );
            Matcher matcher = pattern.matcher(commandResult);
            while(matcher.find()){ 
                String path = matcher.group("path").trim();
                candidates.add(path);
            }
        } else if(osName.contains("nix") || osName.contains("nux") || osName.contains("aix")){
            //String commandResult = "/javac: /usr/lib/jvm/java-7-openjdk-amd64/bin/javac /usr/lib/jvm/java-7-openjdk-amd64/bin/javac /usr/lib/jvm/java-7-openjdk-amd64/man/man1/javac.1.gz"; //just for test
            String commandResult = executeCommand(JAVA_LINUX);
            Pattern pattern = Pattern.compile("\\s*((?<path>\\/.*?\\/javac.*?)(\\s|$))", Pattern.CASE_INSENSITIVE );
            Matcher matcher = pattern.matcher(commandResult);
            while(matcher.find()){ 
                String path = matcher.group("path").trim();
                candidates.add(path);
            }
        } else if(osName.contains("mac")){
            //String commandResult = "lrwx-xr-x 1 root wheel 75 Jun 22 10:27 /usr/bin/javac -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/javac"
        	//String commandResult = "/Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home /Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home";        	
            String commandResult = executeCommand(JAVA_MAC);
            if(commandResult.contains("Unable to finad any JVMs matching version"))
            	return candidates;
            Pattern pattern = Pattern.compile("((?<path>\\/.*?\\/Home))", Pattern.CASE_INSENSITIVE );
            Matcher matcher = pattern.matcher(commandResult);
            while(matcher.find()){
                String path = matcher.group().trim();
                candidates.add(path);
            }
        }
        return candidates;
    }