code: public static File findExecutableInDirectory(String executable, File directory) {
          if (directory == null || !directory.isDirectory()) {
              // if the directory is null or not a directory => returning null.
              return null;
          }
          for (String extension : EXECUTABLE_EXTENSIONS) {
              File file = new File(directory, executable + extension);
              if (file.isFile() && file.canExecute()) {
                  return file;
              }
          }
          // Not found.
          return null;
      }
docs: Tries to find the given executable (specified by its name) in the given directory. It checks for a file having
  one of the extensions contained in {@link #EXECUTABLE_EXTENSIONS}, and checks that this file is executable.
  
  @param executable the name of the program to find, generally without the extension
  @param directory  the directory in which the program is searched.
  @return the file of the program to be searched for if found. {@code null} otherwise. If the given directory is
  {@code null} or not a real directory, it also returns {@code null}.