daily pastebin goal
10%
SHARE
TWEET

Untitled

a guest Mar 15th, 2019 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ProcessBuilder pb = new ProcessBuilder("java", "Second App Main Class Name");
  2. pb.start();
  3.    
  4. public int exec(Class<?> clazz) throws IOException,
  5.                                            InterruptedException {
  6.     String javaHome = System.getProperty("java.home");
  7.     String javaBin = javaHome +
  8.             File.separator + "bin" +
  9.             File.separator + "java";
  10.  
  11.     /* This is where you want to set up your Classpath for the second app */
  12.     String classpath = System.getProperty("java.class.path");
  13.     String className = clazz.getCanonicalName();
  14.  
  15.     ProcessBuilder builder = new ProcessBuilder(
  16.             javaBin, "-cp", classpath, className);
  17.  
  18.     Process process = builder.start();
  19.     process.waitFor();
  20.     return process.exitValue();
  21. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top