Exemplo n.º 1
0
  public static String findJavaExecutable(@NotNull final String cmd) {
    final String javaCmd = addExecutableExtension(cmd);

    // Try with '$java.home/bin

    String result = findCmdInDir(new File(java_home), javaCmd);

    if (result == null) {
      // Try with '$java.home/../bin
      result = findCmdInDir(new File(java_home, ".."), javaCmd);
    }

    if (result == null) {
      // Try with environment JAVA_HOME
      if (JAVA_HOME == null) {
        Apb.getEnv().logInfo("JAVA_HOME environment variable not set.\n");
      } else {
        result = findCmdInDir(new File(JAVA_HOME), cmd);

        if (result == null) {
          Apb.getEnv().logInfo("Invalid value for JAVA_HOME environment variable: %s\n", JAVA_HOME);
        }
      }
    }

    if (result == null) {
      Apb.getEnv().logInfo("Looking for '%s' in the PATH.\n", cmd);
      result = javaCmd;
    }

    return result;
  }
Exemplo n.º 2
0
 protected Task() {
   env = Apb.getEnv();
 }