Java File Attribute doesExecutableExist(String executablePath)

Here you can find the source of doesExecutableExist(String executablePath)

Description

does Executable Exist

License

Open Source License

Declaration

public static boolean doesExecutableExist(String executablePath) 

Method Source Code


//package com.java2s;
/*//from   w w  w .ja v a  2s . c o  m
Copyright 2013 Florin Patan. All rights reserved.
Use of this source code is governed by a MIT-style
license that can be found in the LICENSE file.
*/

import java.io.File;

public class Main {
    public static boolean doesExecutableExist(String executablePath) {
        if (new File(executablePath).exists()) {
            return true;
        }
        String systempath = System.getenv("PATH");
        String[] paths = systempath.split(File.pathSeparator);

        for (String path : paths) {
            if (new File(path, executablePath).exists()) {
                return true;
            }
        }

        return false;
    }
}

Related

  1. checkIfExecutableIsInPATH(final String executableName)
  2. ensureExecutable(final File file)
  3. ensureExecutable(IPath path)
  4. ensureFileIsExecutable(String filename)
  5. fileExecute(String path)