code: private Optional<File> which(final String executableName) {
      String systemPath = System.getenv("PATH");
      String[] pathDirs = systemPath.split(File.pathSeparator);
      
      Optional<File> fullyQualifiedExecutable = Optional.absent();
      for(final String pathDir : pathDirs) {
        File file = new File(pathDir, executableName);
        if (file.isFile()) {
          fullyQualifiedExecutable = Optional.of(file);
          break;
        }
      }
      return fullyQualifiedExecutable;
    }
docs: http://www.coderanch.com/t/279002/java-io/java/find-executable-path