/** * run command on the given file * * @param dataPath the path to the jp2 file * @return the path to the converted file * @throws java.io.IOException if the execution of the tool failed in some fashion */ protected File convert(String dataPath) throws IOException { File resultPath = getConvertedPath(dataPath); String[] commandLine = makeCommandLine(dataPath, getCommandPath(), resultPath); ProcessRunner runner = new ProcessRunner(commandLine); log.debug("Running command '" + Arrays.deepToString(commandLine) + "'"); Map<String, String> myEnv = new HashMap<String, String>(System.getenv()); runner.setEnviroment(myEnv); runner.setOutputCollectionByteSize(Integer.MAX_VALUE); // this call is blocking runner.run(); if (runner.getReturnCode() == 0) { return resultPath; } else { String message = "failed to run, returncode:" + runner.getReturnCode() + ", stdOut:" + runner.getProcessOutputAsString() + " stdErr:" + runner.getProcessErrorAsString(); throw new IOException(message); } }