/** * Determines if the JDK is installed, by executing attempting to execute javac. * * @return <tt>true</tt> if javac was successfully executed, otherwise <tt>false</tt> */ protected boolean exists() { FileExecutor exec = new FileExecutor(); String[] output = new String[2]; String[] params = {"javac", "-help"}; return (exec.executeCommand(params, output) == 0); }
/** * Gets the output of the given (console based) commandline * * @param aCommandLine to execute * @param dir the working directory for the execution * @return the result of the command */ public static String getExecOutput(String[] aCommandLine, String dir) { return getExecOutput(aCommandLine, dir, false); }
/** * Runs {@link ExecutableFile} instances collected during unpacking. * * @param executables the executables to run * @throws InstallerException if an executable fails */ private void executeFiles(List<ExecutableFile> executables) { if (!executables.isEmpty()) { FileExecutor executor = new FileExecutor(executables); PromptUIHandler handler = new ProgressHandler(listener, prompt); if (executor.executeFiles(ExecutableFile.POSTINSTALL, matcher, handler) != 0) { throw new InstallerException("File execution failed"); } } }
exitStatus = executeCommand(params, output); if (exitStatus != 0) try paramList.add(buildClassPath(file.toString())); exitStatus = executeCommand(params, output);
/** * Executed a system command and waits for completion. * * @param params system command as string array * @param output contains output of the command index 0 = standard output index 1 = standard * error * @return exit status of process */ public int executeCommand(String[] params, String[] output) { return executeCommand(params, output, null); }
FileExecutor executor = new FileExecutor(); String[] output = new String[2];
stopThread(outMonitorThread, outMonitor); stopThread(errMonitorThread, errMonitor); output[0] = ""; output[1] = e.getMessage() + "\n";
false); executableFiles.add(executableFile); FileExecutor fileExecutor = new FileExecutor(executableFiles); int retval = fileExecutor.executeFiles(ExecutableFile.POSTINSTALL, matcher, this); if (retval == 0)
/** * Internal helper method. * * @param executor The executor, only used when using external compiler. * @param output The output from the compiler ([0] = stdout, [1] = stderr) * @return The result of the compilation. */ private int runCompiler(FileExecutor executor, String[] output, List<String> cmdline) { if (cmdline.get(0).equals(ECLIPSE_COMPILER_NAME)) { return runEclipseCompiler(output, cmdline); } return executor.executeCommand(cmdline.toArray(new String[cmdline.size()]), output); }
FileExecutor executor = new FileExecutor(); String output[] = new String[2];
/** * Test if KDE is installed. This is done by <code> $>/usr/bin/env kwin --version</code> This * assumes that kwin, the window Manager, as part of the kde-base package is already installed. * If this returns with 0 kwin resp. kde means to be installed, * * @return true if kde is installed otherwise false. */ public static boolean kdeIsInstalled() { FileExecutor fileExecutor = new FileExecutor(); String[] execOut = new String[2]; int execResult = fileExecutor.executeCommand(new String[]{"/usr/bin/env", "kwin", "--version"}, execOut); return execResult == 0; }
/** * Gets the output of the given (console based) commandline * * @param aCommandLine to execute * @return the result of the command */ public static String getExecOutput(String[] aCommandLine) { return getExecOutput(aCommandLine, null, false); }
/** * Executes the given Command and gets the result of StdOut, or if exec returns !=0: StdErr. * * @param aCommandLine aCommandLine to execute * @param dir the working directory for the execution * @param forceToGetStdOut if true returns stdout * @return the result of the command stdout or stderr if exec returns !=0 */ private static String getExecOutput(String[] aCommandLine, String dir, boolean forceToGetStdOut) { FileExecutor fileExecutor = new FileExecutor(); String[] execOut = new String[2]; int execResult = fileExecutor.executeCommand(aCommandLine, execOut, dir); if (execResult == 0) { return execOut[0]; } else if (forceToGetStdOut) { return execOut[0]; } else { return execOut[1]; } }
/** * Gets the output of the given (console based) commandline * * @param aCommandLine to execute * @param forceToGetStdOut if true returns stdout * @return the result of the command */ public static String getExecOutput(String[] aCommandLine, boolean forceToGetStdOut) { return getExecOutput(aCommandLine, null, forceToGetStdOut); }
FileExecutor fe = new FileExecutor(); fe.executeCommand(params, output); ret = extractLong(output[0], -3); FileExecutor fe = new FileExecutor(); fe.executeCommand(params, output); ret = extractLong(output[0], -3) * 1024; FileExecutor fe = new FileExecutor(); fe.executeCommand(params, output); ret = extractLong(output[0], -3) * 1024; FileExecutor fe = new FileExecutor(); fe.executeCommand(params, output); ret = extractLong(output[0], -3) * 1024;
/** * Gets the absolute Pathe to the given custom command. This is necessary, because the command * may be located at /bin on linux but in /usr/bin on Sun Solaris. Which can locate it in your * $PATH for you. * * @param aCommand a Custom Command * @return /bin/aCommand on linux /usr/bin/aCommand on solaris */ public static String getCustomCommand(String aCommand) { return FileExecutor.getExecOutput(new String[]{whichCommand, aCommand}).trim(); }
int ret = new FileExecutor().executeCommand(_cmd_, execOut, _dir_); if (ret == 0)
/** * Gets the absolute Pathe to the rm (Remove) Command. This is necessary, because the command is * located at /bin on linux but in /usr/bin on Sun Solaris. * * @return /bin/rm on linux /usr/bin/rm on solaris */ public static String getRmCommand() { return FileExecutor.getExecOutput(new String[]{whichCommand, "rm"}).trim(); }
FileExecutor fe = new FileExecutor(); fe.executeCommand(params, output);
/** * Gets the absolute Pathe to the ypcat (YellowPage/NIS Cat) Command. This is necessary, because * the command is located at /bin on linux but in /usr/bin on Sun Solaris. * * @return /bin/ypcat on linux /usr/bin/ypcat on solaris */ public static String getYpCatCommand() { return FileExecutor.getExecOutput(new String[]{whichCommand, "ypcat"}).trim(); }