How can I run a subprocess in Equinox with dynamic bundle installation?

you can use the Equinox Launcher API. Here’s an example of how you can use the Equinox Launcher api to launch a new instance of equinox with a set of bundles: ` EquinoxLauncher launcher = new EquinoxLauncher(); String equinoxHome = “/path/to/equinox/home”; String[] bundlePaths = { “/path/to/bundle1.jar”, “/path/to/bundle2.jar” }; EquinoxRunConfiguration runConfig = launcher.newConfiguration(); runConfig.setWorkingDir(new File(equinoxHome)); runConfig.setFramework(new … Read more

How to redirect ProcessBuilder’s output to a string?

Read from the InputStream. You can append the output to a StringBuilder: BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); StringBuilder builder = new StringBuilder(); String line = null; while ( (line = reader.readLine()) != null) { builder.append(line); builder.append(System.getProperty(“line.separator”)); } String result = builder.toString();

ProcessBuilder: Forwarding stdout and stderr of started processes without blocking the main thread

Use ProcessBuilder.inheritIO, it sets the source and destination for subprocess standard I/O to be the same as those of the current Java process. Process p = new ProcessBuilder().inheritIO().command(“command1”).start(); If Java 7 is not an option public static void main(String[] args) throws Exception { Process p = Runtime.getRuntime().exec(“cmd /c dir”); inheritIO(p.getInputStream(), System.out); inheritIO(p.getErrorStream(), System.err); } private … Read more

Difference between ProcessBuilder and Runtime.exec()

The various overloads of Runtime.getRuntime().exec(…) take either an array of strings or a single string. The single-string overloads of exec() will tokenise the string into an array of arguments, before passing the string array onto one of the exec() overloads that takes a string array. The ProcessBuilder constructors, on the other hand, only take a … Read more