![JAR search and dependency download from the Maven repository](/logo.png)
convex.api.Applications Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of convex-peer Show documentation
Show all versions of convex-peer Show documentation
Convex Peer implementation and APIs
package convex.api;
import java.io.IOException;
public class Applications {
/**
* Helper function to launch a different JVM process with the same classpath.
*
* @param c Main class to launch
* @param args Command line args for launched process
* @return Process instance that can be used to observe exit value etc.
* @throws IOException if IO error occurs
*/
public static Process launchApp(Class> c, String... args) throws IOException {
// construct path to java executable
String separator = System.getProperty("file.separator");
String classpath = System.getProperty("java.class.path");
String path = System.getProperty("java.home") + separator + "bin" + separator + "java";
// construct process arguments
String mainClassName=c.getName();
int nargs=args.length;
String[] pargs=new String[4+nargs];
pargs[0]=path;
pargs[1]="-cp";
pargs[2]=classpath;
pargs[3]=mainClassName;
System.arraycopy(args, 0, pargs, 4, nargs);
ProcessBuilder processBuilder = new ProcessBuilder(pargs);
// Execute process and return Process instance
// Calling code can use Process.wairFor(), exitValue() etc.
Process process = processBuilder.start();
return process;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy