Esempio n. 1
0
  /**
   * Calling this function causes the selected application to launch.
   *
   * @return {@code true} in case launching the application was successful
   */
  @SuppressWarnings("nls")
  public boolean launch(
      @Nonnull final Collection<File> classpath, @Nonnull final String startupClass) {
    final String classPathString = buildClassPathString(classpath);

    Iterable<Path> executablePaths;
    if (OSDetection.isMacOSX()) {
      executablePaths = new MacOsXJavaExecutableIterable();
    } else {
      executablePaths = new JavaExecutableIterable();
    }

    for (Path executable : executablePaths) {
      if (isJavaExecutableWorking(executable)) {
        final List<String> callList = new ArrayList<>();
        callList.add(escapePath(executable.toString()));
        callList.add("-classpath");
        callList.add(classPathString);
        if (snapshot) {
          callList.add("-Dillarion.server=devserver");
        }
        callList.add(startupClass);
        printCallList(callList);
        if (launchCallList(callList)) {
          return true;
        } else {
          LOGGER.error("Error while launching application: {}" + errorData);
        }
      }
    }
    return false;
  }
Esempio n. 2
0
 /**
  * This small utility function takes care for escaping a path. This operation is platform
  * dependent so the result will differ on different platforms.
  *
  * @param orgPath the original plain path
  * @return the escaped path
  */
 private static String escapePath(@Nonnull final String orgPath) {
   if (OSDetection.isWindows()) {
     if (orgPath.contains(" ")) {
       return '"' + orgPath + '"';
     }
     return orgPath;
   }
   return orgPath.replace(" ", "\\ ");
 }