Java File Find findExecutable(String executableName)

Here you can find the source of findExecutable(String executableName)

Description

find Executable

License

Open Source License

Declaration

static public File findExecutable(String executableName) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.*;

public class Main {
    static public File findExecutable(String executableName) {
        String systemPath = System.getenv("PATH");
        String[] pathDirs = systemPath.split(File.pathSeparator);

        File fullyQualifiedExecutable = null;
        for (String pathDir : pathDirs) {
            File file = new File(pathDir, executableName);
            if (file.isFile() && file.canExecute()) {
                fullyQualifiedExecutable = file;
                break;
            }/*  w ww . j a  v a 2  s  . c  o m*/
        }
        return fullyQualifiedExecutable;
    }
}

Related

  1. findByExt(File base, String ext)
  2. findByExtension(final File directory, final String extension)
  3. findByFileName(List files, String fileName)
  4. findExe(String exeName, String... path)
  5. findExecutable(File baseLocation)
  6. findExecutableInDirectory(String executable, File directory)
  7. findExecutableInPath(String exec)
  8. findExecutableInSystemPath(String executable)
  9. findExecutableLocation(String executableName)